Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emmanuelbeziat/encode-image-uri
🖼 Simple plugin to encode images to base64, client-side, with a mimetype conservation (jpg, png, gif, etc).
https://github.com/emmanuelbeziat/encode-image-uri
base64 client-side encoding javascript uri
Last synced: about 2 months ago
JSON representation
🖼 Simple plugin to encode images to base64, client-side, with a mimetype conservation (jpg, png, gif, etc).
- Host: GitHub
- URL: https://github.com/emmanuelbeziat/encode-image-uri
- Owner: EmmanuelBeziat
- License: mit
- Created: 2018-08-13T22:39:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-14T15:53:41.000Z (over 6 years ago)
- Last Synced: 2024-08-11T09:48:17.449Z (5 months ago)
- Topics: base64, client-side, encoding, javascript, uri
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# encode-image-uri
Simple plugin to encode images to base64, with a mimetype conservation (jpg, png, gif, etc).
## Installation
```bash
# npm
$ npm i encode-image-uri# yarn
$ yarn add encode-image-uri
```## How to use
```javascript
const encodeImageURI = require('encode-image-uri')encodeImageURI(image)
.then(base64 => {
console.log(base64)
// Do your stuff
})
.catch(error => {
console.error(error)
// Handle your error
})
```Note that the image fiven must be a File object.
## Example
### Image from an input with multiple files
```html
```
```javascript
documment.querySelector('.input-file').addEventListener(event, (event) => {
const fileList = event.target.filesArray.from(fileList).forEach(image => {
encodeImageURI(image).then(base64 => {
console.log(base64)
})
})
})
```## Contribute
I’ll happily get your PR :)