npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

image2tags

v0.0.4

Published

An npm package that generates keywords from an image

Readme

Image to Tags

This package uses TensorFlow.js and the pre-trained MobileNet model to recognize objects and scenes in an image and generate relevant keywords (tags).

NPM Version NPM Downloads

Features

  • Processes images from a local file path.
  • Uses the popular and efficient MobileNet model.
  • Written in TypeScript and includes type definitions.
  • Provides an easy-to-use and flexible API.

Installation

You can add the package to your project using npm or yarn:

npm install image2tags

or

yarn add image2tags

Usage

After importing the package into your project, you can use the getImageTags function. This function takes the file path of an image as a parameter and returns a Promise. This Promise resolves with an array containing the tags and their probabilities.

import { getImageTags } from 'image2tags';
import * as path from 'path';

async function main() {
  try {
    const imagePath = path.join(__dirname, 'path/to/your/image.jpg');
    const tags = await getImageTags(imagePath);
    
    console.log('Detected Tags:');
    tags.forEach(tag => {
      console.log(`- ${tag.className} (Probability: ${(tag.probability * 100).toFixed(2)}%)`);
    });
  } catch (error) {
    console.error('An error occurred while getting tags:', error);
  }
}

main();

CLI Usage

You can also use this package as a command-line tool.

image2tags <path/to/your/image.jpg>

Options:

  • -k, --topK <number>: Specify the number of top predictions to return (default: 10).
  • --json: Output results in JSON format.

Example:

image2tags tests/fixtures/sample.jpg -k 5

Example with JSON output:

image2tags tests/fixtures/sample.jpg --json

Which will produce the following output:

[
  {
    "className": "brass, memorial tablet, plaque",
    "probability": 0.28563258051872253,
    "tags": [
      "brass",
      "memorial tablet",
      "plaque"
    ]
  },
  {
    "className": "envelope",
    "probability": 0.19800801575183868,
    "tags": [
      "envelope"
    ]
  }
]

Parameters

  • imagePath (string, required): The file path of the image to be processed.
  • topK (number, optional, default: 10): The number of top predictions to return.

Running Tests

To run the tests, clone the project, install the dependencies, and then run the test command:

git clone https://github.com/litepacks/image2tags.git
cd image2tags
npm install
npm test

Note: For the tests to run, there must be an image file named sample.jpg in the tests/fixtures folder.

Contributing

Contributions are always welcome! Please open an issue to discuss your proposed changes before submitting a pull request.

License

This project is licensed under the MIT License.