JavaScript image dithering tools for Sharp
npm install sweetcornsweetcornJavaScript image dithering tools for Sharp
``bash`
npm install sweetcorn
`js
import sharp from 'sharp';
import sweetcorn from 'sweetcorn';
const inputImage = await sharp('input.png');
const ditheredImage = await sweetcorn(inputImage, {
algorithm: 'floyd-steinberg',
});
ditheredImage.webp({ lossless: true }).toFile('output.webp');
``
Learn more in the Sweetcorn documentation site.