In my node application fs
and gm
to copy and conversion img file,
How to check whether the copy and conversion particular stream is complete or not ?
ex: Img is picture url array.
for (var i = 0; i < Img.length; i++) {
// copy img file , how to check this [i] img is copy complete
fs.createReadStream('/' + Img[i]).pipe(fs.createWriteStream('/' + pngImg[i] + '_copy.png');
gm('/' + Img[i].'_copy.png')
.stream('jpg', function (err, stdout, stderr) {
fs.createWriteStream('/' + Img[i].jpg);
stdout.pipe(writeStream);
}); // conversion img png to jpg , how to check this [i] img is conversion complete
fs.unlink('/' + Img[i] + '_copy.png'), function (err) {
console.log('successfully deleted');
});
}
Or whether there is a better way? to complete copy, conversion and delete.