Making a CMYK image with nodeJS pixel per pixel

349 Views Asked by At

Context: I have a printer and the color are noot good. I would like to make a test file that has a wide range of colors.

Problem: I need to make a square with as many colors as possible using CMYK format?

Practical obstacles: How can I transform an array of hex numbers into a CMYK image. I have found https://www.npmjs.com/package/jimp and https://www.npmjs.com/package/sharp. Maybe I am just not used to these tools but I didnt found on the documentation how I can make an image from scratch using CMYK color format.

EDIT: I would like to choose the colors: it would look like something like this:

const image = new Jimp(3, 3, function (err, image) {


if (err) throw err;
    for (var row=0; row<3; row++) {
        for (var column=0; column<3; column++) {
            const cyan=0
            const magenta=100
            const yellow=column*60
            const key = 255
            const color=Jimp.cmykToInt(red, magenta, yellow, key)
            image.setPixelColorCMYK(color, column, row);
        }
    }

  image.write('squareImage.tif', (err) => {
// or any format compatible with CMYK
    if (err) throw err;
  });
});

Of course it can use Jimp or any other nodejs package

0

There are 0 best solutions below