简体   繁体   中英

How get buffer value of converted Image

I badly need a Image manipulating library.I am using this JIMP library for image manipulation seems to be good documented.But i am little bit confused that how to get the buffer size of converted Image

let ImageURI = req.body.data.thumbnailBlob;

let buf = new Buffer(ImageURI.replace(/^data:image\/\w+;base64,/, ""),'base64');

Jimp.read(buf,(err,image) => {
   if(err) {
       console.log(err)
   }
   image.cover(250,250)
       .getBuffer( "image/jpeg",(Buff) => {
           console.log(Buff)//null
       })
})

Buff is null because first argument is "err" you need to add it as a first argument

image.cover(250,250)
       .getBuffer( "image/jpeg",**(err,Buff)** => {
           console.log(Buff)//null
       })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM