Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/riyadhalnur/node-base64-image
Download images from remote URLs or use local images and encode/decode them to Base64 string or Buffer object
https://github.com/riyadhalnur/node-base64-image
base64 decode decoder encode encoder javascript nodejs typescript
Last synced: 4 days ago
JSON representation
Download images from remote URLs or use local images and encode/decode them to Base64 string or Buffer object
- Host: GitHub
- URL: https://github.com/riyadhalnur/node-base64-image
- Owner: riyadhalnur
- License: mit
- Created: 2014-12-08T11:49:56.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-15T21:48:57.000Z (3 months ago)
- Last Synced: 2024-11-06T17:58:20.338Z (11 days ago)
- Topics: base64, decode, decoder, encode, encoder, javascript, nodejs, typescript
- Language: TypeScript
- Homepage: http://riyadhalnur.github.io/node-base64-image
- Size: 1.03 MB
- Stars: 133
- Watchers: 5
- Forks: 38
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
![Node.js Package](https://github.com/riyadhalnur/node-base64-image/workflows/Node.js%20Package/badge.svg?branch=master)
node-base64-image
=================Download images from remote URLs or use local images and encode/decode them to Base64 string or [Buffer](https://nodejs.org/api/buffer.html) object
### Installation
`npm i node-base64-image --save`### Usage
```js
const base64 = require('node-base64-image');
// or
import {encode, decode} from 'node-base64-image';
```### Examples
```js
// encoding a remote jpg to base64
const url = 'https://example.com/test.jpg';
const options = {
string: true,
headers: {
"User-Agent": "my-app"
}
};
const image = await encode(url, options);// encoding a local file
const localUrl = 'C:/project/test.jpg';
const localImage = await encode(url, {string: true, local: true});// writing to file named 'example.jpg'
await decode(image, { fname: 'example', ext: 'jpg' });// writing to a sub-directory
// after creating a directory called 'photos'
const image = await encode(url, options);
await decode(image, { fname: './photos/example', ext: 'jpg' });
```### Contributing
Read the [CONTRIBUTING](CONTRIBUTING.md) guide for information.### License
Licensed under MIT. See [LICENSE](LICENSE) for more information.### Issues
Report a bug in issues.Made with love in Dhaka, Bangladesh by [Riyadh Al Nur](https://verticalaxisbd.com)