Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@digitalmasterpieces/styles-client

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-87.5%
Maintainers
2
Weekly downloads
 
Created
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

Package last updated on 16 Dec 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc