base64-image
Get base64 encoded image file
Install
$ npm install @guntur/base64-image
Usage
const base64Image = require('@guntur/base64-image');
const imgPath = '/path/to/image.png';
base64Image.encoder(imgPath).then(base64String => {
console.log(base64String);
//=> 'data:image/png;base64,iVBORw0KGgoAAA...TkSuQmCC'
});
console.log(base64Image.encoder.sync(imgPath));
//=> 'data:image/png;base64,iVBORw0KGgoAAA...TkSuQmCC'
API
filepath
)
base64Image.encoder(- Params:
-
filepath
:<string>
- (required)
-
- Returns:
Promise<string>
filepath
)
base64Image.encoder.sync(- Params:
-
filepath
:<string>
- (required)
-
- Returns:
<string>
License
MIT © Guntur Poetra