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

ablend

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ablend

Combines 2 images (one on white and one on black) to produce a transparent version.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ablend

Combines 2 images (one on white and one on black) to produce a transparent version.

Based on my old screenshot tool for Linux abscapture and my Compiz 0.8 plugin windowcapture. Inspired by Windows screenshot tool Window Clippings.

This app doesn't have screenshot facilities, just the ability to blend together two images to produce a transparent image.

API

var ablend = require('ablend');

exports.ablend(a, b, o, onprogress)

Blends the images a and b and save into o.

a, b and o must be an ImageData object and have same dimensions.

  • a - an ImageData object representing an image on black background, read-only
  • b - an ImageData object representing an image on white background, read-only
  • o - an ImageData object representing the output image, write-only
  • onprogress - function(current, total) will be fired every pixel processed

exports.cblend(ca, cb, ba, bb, o)

Blends two colors ca and cb and save the result into o.

The color o will be set so that when it is displayed on ba will result in ca and when displayed on bb will result in cb.

  • ca - the color object for the color that is displayed on ba.
  • cb - the color object for the color that is displayed on bb.
  • ba - the color object for first background color.
  • bb - the color object for second background color.
  • o - the color object for output.
Color Objects
{
  "r": (red value from 0 to 255),
  "g": (green value from 0 to 255),
  "b": (blue value from 0 to 255),
  "a": (alpha value from 0 to 255)
}

exports.alpha(va, vb, ba, bb)

Given two colors and two backgrounds, compute the opacity.

  • va - the value of the color on background A.
  • vb - the value of the color on background B.
  • ba - the value of the background color A.
  • ba - the value of the background color B.
  • Returns the alpha value, between 0 and 1 inclusive.
Color Values

The value of a color is defined to be the sum of red, green and blue channel.

For example, the value of black is 0, and white is 765 (255*3).

exports.value(va, vb, ba, bb, a)

  • va - the value of the color on background A.
  • vb - the value of the color on background B.
  • ba - the value of the background color A.
  • bb - the value of the background color A.
  • a - the alpha value, returned by exports.alpha.
  • Returns the color value, that will result in va when displayed with opacity a on background color ba, and vb when displayed on background color bb.
Color Values

For this function, the value of the color is the value of each channel.

Dependencies

The core algorithm (lib/ablend.js) doesn't depend on anything, but the CLI script uses learnboost/node-canvas to read and write images and substack/node-optimist to parse command-line arguments.

FAQs

Package last updated on 17 Nov 2020

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