You can encode your image(jpg/png) to base64 and decode your base64 to image(png/jpg)
npm install imgconversionimgconversion is used to convert an image to base64 and base64 to image
npm install imgconversion
and you can use it like
const imgconversionpackage = require(‘imgconversion’);
let base64string = imgconversionpackage.imgtobase64(’./example.png’);
So in base64string you will get your base64 data.
imgconversionpackage.base64toimg(base64string,‘jpg’)
The file will be created with the name of example.jpg in your project folder.
imgconversionpackage.base64toimg(base64string,‘png’)
The file will be created with the name of example.png in your project folder.
Credits: Pradeepa Anumalla