How To Covert Base64 Encoded Image To A Tiff/png/jpeg Using Nodejs
I have a image that is in base64 string that I would like to convert to a graphic format such as TIFF, BMP, or JPG. base64string = 'data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO
Solution 1:
I got solution for this by using sharp npm module we can do this
npm install sharp --save
const sharp = require('sharp'); var img_src = base64_string; const base64Data = newBuffer(img_src.replace(/^data:image\/\w+;base64,/, ""), 'base64') sharp(base64Data) .tiff({ compression: 'lzw', squash: true }) .background('white') .embed() .toBuffer() .then(data_img => { // tiff image data });
Post a Comment for "How To Covert Base64 Encoded Image To A Tiff/png/jpeg Using Nodejs"