https://github.com/tiaanduplessis/image-to-uri
Convert image file to data URI
https://github.com/tiaanduplessis/image-to-uri
base64 fs image jpeg jpg png uri
Last synced: 2 months ago
JSON representation
Convert image file to data URI
- Host: GitHub
- URL: https://github.com/tiaanduplessis/image-to-uri
- Owner: tiaanduplessis
- License: mit
- Created: 2017-04-21T22:37:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T22:56:10.000Z (over 6 years ago)
- Last Synced: 2025-07-21T12:52:51.222Z (3 months ago)
- Topics: base64, fs, image, jpeg, jpg, png, uri
- Language: JavaScript
- Size: 323 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
image-to-uri
Convert image file to data URI
Table of Contents
Table of Contents
## Install
[](https://greenkeeper.io/)
```sh
$ npm install --save image-to-uri
# OR
$ yarn add image-to-uri
```
## Usage
```js
const imageToUri = require('image-to-uri')
console.log(imageToUri('./example.jpg')) // data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB...
```
Supported image types:
- png
- gif
- jpg
- jpeg
- bm
- bmp
- webp
- ico
- svg
## CLI
```sh
$ npm install --global image-to-uri
# OR
$ yarn global add image-to-uri
```
Then:
```sh
$ image-to-uri ./example.jpg
# data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQAB...
$ image-to-uri ./example.jpg | pbcopy
# pipe to clipboard(macOS)
```
## Contribute
Contributions are welcome. Please open up an issue or create PR if you would like to help out.
Note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
## License
Licensed under the MIT License.