Soham Krishna Paul
Soham Krishna Paul
Node JS Developer PHP Developer React-Native Developer React JS Developer Web Developer
Soham Krishna Paul

Blog

Tiff convert to png Node js

Tiff convert to png Node js

1st You have to install "Imagemagick"

  1. For windows, you will find .exe file. Keep it in your mind that on installation time, check "Install legacy utilities (e.g: convert)"

  2. For Ubuntu:

sudo apt install imagemagick

  1. For Cent OS:

sudo yum install ImageMagick

Now Check the Sample Code given below.
var fs=require('fs');
var spawn = require('child_process').spawn;
//ifile: Tiff Absolute File Path
//ofile: PNG Absolute File Path (e.g: var ofile = APP_ROOT_PATH+'/data/files/png/sample.png';)
var tiff2png = spawn('convert', [ifile, ofile]);
tiff2png.stdout.on('data', function (data) {
    console.log('stdout: ' + data);
});
tiff2png.stderr.on('data', function (data) {
    return res.json(Utility.output('Unable to convert tiff to png','ERROR'));
    console.log('stderr: ' + data);
});
tiff2png.on('close', function (code) {
    /**Check Your Converted file exist or not. If exist then Converted**/
    console.log('Close: ' + data);
});
tiff2png.on('error', function (code) {
    return res.json(Utility.output('ERROR: Unable to convert tiff to png','ERROR'));
});

Add Comment