imgconversion

1.0.7 • Public • Published

imgconversion

imgconversion is used to convert an image to base64 and base64 to image

  • You can give either png or jpg image to encode it to base64
  • You can decode your base64 to jpg or png()

imgtobase64

  • imgbase64(path) function will convert your image to base64.You have to give the path of your file in the path parameter.

base64toimg

  • base64toimg(base64,format) will convert base64 into jpg or png.The first parameter in this function is your base64 string and second parameter is the format in which you want to get your file (jpg/png).The file will be created in the name of example.png in your project folder.

install the package by using below command

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

Package Sidebar

Install

npm i imgconversion

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

2.35 kB

Total Files

3

Last publish

Collaborators

  • pradeepaanumalla