Socket
Socket
Sign inDemoInstall

@digitalmasterpieces/styles-client

Package Overview
Dependencies
10
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @digitalmasterpieces/styles-client

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


Version published
Weekly downloads
2
decreased by-75%
Maintainers
2
Install size
0.983 MB
Created
Weekly downloads
 

Readme

Source

@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

Keywords

FAQs

Last updated on 16 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc