2016-12-07 31 views
0

我非常需要一個圖像操作庫。我正在使用這個JIMP庫進行圖像處理似乎是很好的記錄。但我有點困惑,如何獲得轉換圖像的緩衝區大小如何獲得轉換圖像的緩衝區值

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

回答

1

的Buff爲null,因爲第一個參數是「犯錯」你需要把它添加爲第一個參數

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