You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ditherjs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ditherjs

Image dithering library

0.10.0
latest
Source
npmnpm
Version published
Weekly downloads
412
-52.91%
Maintainers
1
Weekly downloads
 
Created
Source

ditherJS

License: CC BY-SA 4.0 Build Status Coverage Status

A javascript library which dithers an image using a fixed palette.

Run npm run demo:client or npm run demo:sever to see it in action.

Installation and dependencies

$ npm install ditherjs --save

Both client and server are exposed as commonJS modules to be used with webpack or browserify.

The client-side version is also published with an UMD compatible wrapper and a jQuery plugin, those versions are in ./dist

The server-side version needs node-canvas installed as a peer dependency to work, this is also needed to run run the tests during development.

$ npm install ditherjs canvas --save

Usage and options

Any DitherJS instance exposes a dither(target, [options]) method which accepts a selector a Node or a buffer as a target and an optional options object.

The options can be passed directly to the method or directly in the constructor.

var options = {
    "step": 1, // The step for the pixel quantization n = 1,2,3...
    "palette": defaultPalette, // an array of colors as rgb arrays
    "algorithm": "ordered" // one of ["ordered", "diffusion", "atkinson"]
};

A default palette is provided which is CGA Palette 1

Rick dangerhous II

The palette structure is as an array of rgb colors [[r,g,b]..]

Client

var DitherJS = require('ditherjs');

var ditherjs = new DitherJS([,options]);
ditherjs.dither(selector,[,options]); // should target <img> elements

as a jQuery plugin

$('.dither').ditherJS(options);

or directly on the element

<img src="..." onload="ditherjs.dither(this)" />

Server

var DitherJS = require('ditherjs/server');

var ditherjs = new DitherJS([,options]);

// Get a buffer that can be loaded into a canvas
var buffer = fs.readFileSync('./myBeautifulFile.jpg|gif|png');

ditherjs.dither(buffer,[,options]);

Testimonials

Useful as a comb to a bald man. -Anon

author 2014 Daniele Piccone

Keywords

graphic

FAQs

Package last updated on 26 Oct 2018

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