# encode-image-uri

> Simple plugin to encode images to base64, with a mimetype conservation (jpg, png, gif, etc)

Latest version **2.0.0** (published 2018-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install encode-image-uri
pnpm add encode-image-uri
yarn add encode-image-uri
bun add encode-image-uri
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2018-08-14 |
| First published | 2018-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | EmmanuelBeziat |
| Maintainers | emmanuelbeziat |
| Keywords | browser, image, canvas, base64 |

## Links

- npm: https://www.npmjs.com/package/encode-image-uri
- Repository: https://github.com/EmmanuelBeziat/encode-image-uri
- Homepage: https://github.com/EmmanuelBeziat/encode-image-uri#readme
- Issues: https://github.com/EmmanuelBeziat/encode-image-uri/issues
- npm.io page: https://npm.io/package/encode-image-uri

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2018-08-14
- 1.0.3 — 2018-08-13
- 1.0.2 — 2018-08-13
- 1.0.1 — 2018-08-13
- 1.0.0 — 2018-08-13

## 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
<input type="file" class="input-file" multiple>
```

```javascript
documment.querySelector('.input-file').addEventListener(event, (event) => {
	const fileList = event.target.files

	Array.from(fileList).forEach(image => {
		encodeImageURI(image).then(base64 => {
			console.log(base64)
		})
	})
})
```

## Contribute

I’ll happily get your PR :)

---
_Source: https://npm.io/package/encode-image-uri · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
