Socket
Socket
Sign inDemoInstall

node-pixels

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-pixels

Pixels.js Adapter for Node (https://silvia-odwyer.github.io/pixels.js/)


Version published
Weekly downloads
228
increased by39.88%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Pixels Library

npm version

Library for image web manipulation. Using the Pixels.js library (https://silvia-odwyer.github.io/pixels.js/)

Table of Contents

Installation

You can install the Pixels Image React Component using npm:

npm install node-pixels

or yarn:

yarn add node-pixels

Usage

Basic Use

import Pixels from 'node-pixels';

async function loadFilter(element) {
  const canvas = document.createElement("canvas"); // create canvas
  const source = await Pixels.getImageSource(element); // get source of <img> element
  let { context, data } = await Pixels.drawImageSource(canvas, source); // draw image into canvas
  await Pixels.adjustColors(data, {
    brightness: 0.5,
    saturation: 0.2,
    contrast: -0.3
  }); // adjust colors (example values)
  await Pixels.loadFilter(data, "coral"); // or ["coral", ...] to apply more than one filter
  await Pixels.applyChanges(data, context); // apply changes into context
  await Pixels.setVerticalFlip(canvas, context); // apply vertical flip
  await Pixels.setHorizontalFlip(canvas, context); // apply horizontal flip
  element.src = canvas.toDataURL("image/png"); // draw image into element (change mimetype if is needed) 

  // reset changes:
  Pixels.reset(source, context);
  element.src = canvas.toDataURL("image/png"); // draw image into element (change mimetype if is needed)
}

loadFilter(document.getElementById("my-image"));

Keywords

FAQs

Last updated on 11 Sep 2023

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