Skip to content

Commit

Permalink
readme updates to address #34
Browse files Browse the repository at this point in the history
  • Loading branch information
catdad authored Dec 2, 2024
1 parent c26f985 commit baf860e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
npm install heic-convert
```

## Usage

You can convert the first image in a HEIC, or convert all images in the file. In both cases, the options are the same.

### options object

* `buffer` - a Node [`Buffer`](https://nodejs.org/api/buffer.html) or a [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) - the HEIC image to convert
* `format` - string - either `JPEG` or `PNG`
* `quality` - number between `0` and `1`, optional - the lossy compression quality to be used when converting to jpeg.

## Usage in NodeJS

Convert the main image in a HEIC to JPEG
Expand All @@ -30,9 +40,9 @@ const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const outputBuffer = await convert({
buffer: inputBuffer, // the HEIC file buffer
format: 'JPEG', // output format
quality: 1 // the jpeg compression quality, between 0 and 1
buffer: inputBuffer,
format: 'JPEG',
quality: 1
});

await promisify(fs.writeFile)('./result.jpg', outputBuffer);
Expand All @@ -49,8 +59,8 @@ const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const outputBuffer = await convert({
buffer: inputBuffer, // the HEIC file buffer
format: 'PNG' // output format
buffer: inputBuffer,
format: 'PNG'
});

await promisify(fs.writeFile)('./result.png', outputBuffer);
Expand All @@ -67,8 +77,8 @@ const convert = require('heic-convert');
(async () => {
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
const images = await convert.all({
buffer: inputBuffer, // the HEIC file buffer
format: 'JPEG' // output format
buffer: inputBuffer,
format: 'JPEG'
});

for (let idx in images) {
Expand Down

0 comments on commit baf860e

Please sign in to comment.