Ted
Ted

Reputation: 1760

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.

Upvotes: 0

Views: 2165

Answers (1)

Anatoly
Anatoly

Reputation: 22813

Just use toString method of Buffer like this:

const resInBase64 = res.toString('base64')

Upvotes: 2

Related Questions