imgconversion
Version:
You can encode your image(jpg/png) to base64 and decode your base64 to image(png/jpg)
25 lines • 1.54 kB
Markdown
<h1><a id="imgconversion_0"></a>imgconversion</h1>
<p>imgconversion is used to convert an image to base64 and base64 to image</p>
<ul>
<li>You can give either png or jpg image to encode it to base64</li>
<li>You can decode your base64 to jpg or png()</li>
</ul>
<h1><a id="imgtobase64_7"></a>imgtobase64</h1>
<ul>
<li>imgbase64(path) function will convert your image to base64.You have to give the path of your file in the path parameter.</li>
</ul>
<h1><a id="base64toimg_11"></a>base64toimg</h1>
<ul>
<li>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.</li>
</ul>
<h1><a id="install_the_package_by_using_below_command_14"></a>install the package by using below command</h1>
<p>npm install imgconversion<br>
and you can use it like<br>
const imgconversionpackage = require(‘imgconversion’);<br>
let base64string = imgconversionpackage.imgtobase64(’./example.png’);<br>
So in base64string you will get your base64 data.<br>
imgconversionpackage.base64toimg(base64string,‘jpg’)<br>
The file will be created with the name of example.jpg in your project folder.<br>
imgconversionpackage.base64toimg(base64string,‘png’)<br>
The file will be created with the name of example.png in your project folder.</p>
<p><code style="color:red">Credits:</code> Pradeepa Anumalla</p>