简体   繁体   中英

Convert image buffer to base64

I am resizing base64 image with jimp:

   const buffer = Buffer.from(Photo, 'base64');
   const { mime } = fileType(buffer);
   const photoBuffer = await jimp.read(buffer);

   const res = await photoBuffer.cover(10, 10)
       .quality(30).getBufferAsync(mime);

now I need to conver 'res' buffer back to base64.

Just use toString method of Buffer like this:

const resInBase64 = res.toString('base64')

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