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 🙏

© 2024 – Pkg Stats / Ryan Hefner

img-processing-sdk

v1.2.0

Published

SDK for image processing

Downloads

617

Readme

IMG Processing Node SDK

This is a Node.js SDK for the IMG Processing API.

We have implemented a nice SDK that provides a simple and easy-to-use way to interact with the IMG Processing API, a powerful and flexible API provides a wide range of image manipulation and analysis capabilities, allowing developers to integrate advanced image processing features into their applications with ease.

Overview

IMG Processing API SDK is a set of tools that allow you to interact with the IMG Processing API from your application. The SDK provides three basic elements, the IMGProcessingClient, the ImageObject, and the IMGProcessingAPIError classes.

Soon we will talk more about each of these elements, but first, let's see how to install the SDK in your project.

Installation

You can install the SDK using a package manager:

npm install img-processing-sdk

Authentication

After installing the SDK, you need to authenticate your requests using your API key. Check out the Authentication section for more information about how to get an API key.

After getting your API key, use it as an environment variable or application argument to prevent hardcoding it in your code, and keep it secure.

Using the SDK

To start using the SDK, you need to import the IMGProcessingClient class and create an instance of it.

import { IMGProcessingClient } from 'img-processing-sdk';

const client = new IMGProcessingClient({
    apiKey: process.env.IMG_PROCESSING_API_KEY,
});

Width the client, you can interact with many functions, for example, let's upload an image:

const image = await client.uploadImage({
    file: 'path/to/image.jpg',
    name: 'image.jpg',
});

After uploading the image, you can use the ImageObject returned and interact with it, for example, resizing the image:

const resizedImage = await image.resize({
    width: 200,
    height: 200,
});

Or you can do the same operation using the client:

const resizedImage = await client.resizeImage({
    image_id: image.id,
    width: 200,
    height: 200,
});

If there is an error in the request, the SDK will throw an IMGProcessingAPIError with the error message.

try {
    const resizedImage = await client.resizeImage({
        image_id: 'image_exampleid',
        width: 200,
        height: 200,
    });
} catch (error) {
    console.error(error);
}

// Output:
// IMGProcessingAPIError {
//   type: 'https://docs.img-processing.com/errors/not-found',
//   error: 'Not Found',
//   status: 404,
//   message: 'Image with id image_exampleid not found.',
//   errors: undefined
// }

Billing

All the request to the API that return a 201 status code will be counted as a processed image. There are some endpoints that could be counted as multiple images processed, since they execute two or more operations, in that case, the docs will specify how many images will be counted for that operation.

Test images are not counted in the billing.

Contributing

If you want to contribute to the SDK, please check the Contributing guide.