[英]Convert image buffer to base64
I am resizing base64 image with jimp:我正在使用 jimp 调整 base64 图像的大小:
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.现在我需要将“res”缓冲区转换回 base64。
Just use toString
method of Buffer
like this:只需像这样使用Buffer
的toString
方法:
const resInBase64 = res.toString('base64')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.