Skip to content

Commit

Permalink
Merge pull request #77 from drewB/patch-1
Browse files Browse the repository at this point in the history
Update README.md to include example for encoding from local file
  • Loading branch information
riyadhalnur authored Jul 12, 2024
2 parents 5dea6ee + c07106f commit 9ee3f22
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ import {encode, decode} from 'node-base64-image';

### Examples
```js
// encoding a jpg to base64
// 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'
const image = await encode(url, options);
await decode(image, { fname: 'example', ext: 'jpg' });

// writing to a sub-directory
Expand Down

0 comments on commit 9ee3f22

Please sign in to comment.