danielepiccone / ditherjs

A javascript library which dithers an <img> using a fixed palette
http://danielepiccone.github.io/ditherjs/
133 stars 21 forks source link

InvalidAlgorithm #10

Closed 1Euro7Cent closed 2 years ago

1Euro7Cent commented 3 years ago

I've made the example stuff image

the color array: image err: image

additional information: windows 10 pro 64bit

node: v14.16.0 npm: 6.14.11

Did I make anything wrong?

bogstandard commented 2 years ago

Had this issue too, it looks like the documentation is incorrect and the options should be given in the following way:


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

const ditherjs = new DitherJS(options);
ditherjs.dither('img', options); // should target <img> elements
1Euro7Cent commented 2 years ago

I already fixed it by looking into the source code. I forgot about this issue existing. But thank you.