Jimp: How get buffer of converted Image

Created on 7 Dec 2016  路  2Comments  路  Source: oliver-moran/jimp

hi
Is that possible to get Buffer of converted Image.I've tried it but it return null

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
           })
    })
question

Most helpful comment

@githubitsme Same issue here, how did you managed to overcome this situation?

Edit:

Since I always work with promises, I forgot to include in the callback parameters error and result:

image.getBuffer(Jimp.MIME_PNG, (error, result) => ...

the null is because no erro was found.

Hope help some absent minded like me :)

All 2 comments

@githubitsme Same issue here, how did you managed to overcome this situation?

Edit:

Since I always work with promises, I forgot to include in the callback parameters error and result:

image.getBuffer(Jimp.MIME_PNG, (error, result) => ...

the null is because no erro was found.

Hope help some absent minded like me :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codan84 picture codan84  路  25Comments

mkondel picture mkondel  路  14Comments

marcolino picture marcolino  路  21Comments

RomainFallet picture RomainFallet  路  26Comments

yangshenhuai picture yangshenhuai  路  16Comments