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

@digitalmasterpieces/styles-client

v2.3.1

Published

Client for processing images via the Stylization-as-a-Service REST API by Digital Masterpieces GmbH.

Downloads

58

Readme

@digitalmasterpieces/

styles-client

npm npm License npm bundle size Libraries.io dependency status for latest release, scoped npm package Type declarations

Client for processing images via the Stylization-as-a-Service REST API by Digital Masterpieces GmbH.

Installing

You can install the StylesClient using NPM or Yarn to get the latest version of our library.

npm install @digitalmasterpieces/styles-client

For usage from a CDN we recommend using Skypack CDN. The StylesClient package is accessable at the following URL:

https://cdn.skypack.dev/@digitalmasterpieces/styles-client


Usage

When using the CDN URL you need to add your script tag of type module to the HTML. Then you can initialize the client as follows:

import StylesClient from "https://cdn.skypack.dev/@digitalmasterpieces/styles-client";

const client = new StylesClient({
	apiKey: { id: "<your-key-id>", key: "<your-api-key>" },
});

Otherwise, when using Node.js in combination with TypeScript or ES modules:

import StylesClient from "@digitalmasterpieces/styles-client";

const client = new StylesClient({
	apiKey: { id: "<your-key-id>", key: "<your-api-key>" },
});

With the client initialized you can use it as follows:

import { Pipeline } from "@digitalmasterpieces/styles-client";

// Get a list of all available processing operations
const operations = await client.getOperations();

// Get a specific operation you want to use for processing
const operation = await client.getOperation(operations[0].id);

// Create a processing pipeline and use it for processing an image
const pipeline = new Pipeline();

pipeline.add(operation);

const image = /* your image to process */
const processedImage = await client.process(image, pipeline);

When using the client in browser your image should be a File. When you use the client on server-side with Node.js you could use either a Buffer or a Readable stream.

In browser this could look like:

const image = document.querySelector("#file-input").files[0];

In Node.js you could achieve it with the following:

// Using an image from file system as a readable stream
const image = {
	data: fs.createReadStream(path.join(IMAGE_DIR, "image.png")),
	mimetype: "image/png",
	name: "image.png",
};

// Using an image from file system as a buffer
const image = {
	data: fs.readFileSync(path.join(IMAGE_DIR, "image.png")),
	mimetype: "image/png",
	name: "image.png",
};

The full documentation with some usage examples is available here.

To learn more about the Stylization SDK visit our homepage at https://saas.digitalmasterpieces.com.

Get your own API key here.

Try our demo application here.

License

MIT