node.jsnode-modulesrgbcolor-spacecmyk

Converting an image from RGB to CMYK with Node JS


My printer only work on CMYK colors. And I want to make a telegram bot with node js. I searched on internet to directly transform image color space. But I cannot find.

For python; I find Image.convert(). Its worked for me. My question is that can I make this with an node package?


Solution

  • Use this awesome npm package called Sharp https://github.com/lovell/sharp

    Installation is:

    npm install sharp
    

    Then your JS is as easy as:

    const sharp = require('sharp');
    
    console.log('Converting...')
    
    sharp('input.jpg')
        .toColourspace('cmyk')
        .toFile('output.jpg')
        .then(() => {
            console.log('Conversion completed!')
    });