Skip to content

Commit baf860e

Browse files
authored
readme updates to address #34
1 parent c26f985 commit baf860e

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
npm install heic-convert
1919
```
2020

21+
## Usage
22+
23+
You can convert the first image in a HEIC, or convert all images in the file. In both cases, the options are the same.
24+
25+
### options object
26+
27+
* `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
28+
* `format` - string - either `JPEG` or `PNG`
29+
* `quality` - number between `0` and `1`, optional - the lossy compression quality to be used when converting to jpeg.
30+
2131
## Usage in NodeJS
2232

2333
Convert the main image in a HEIC to JPEG
@@ -30,9 +40,9 @@ const convert = require('heic-convert');
3040
(async () => {
3141
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
3242
const outputBuffer = await convert({
33-
buffer: inputBuffer, // the HEIC file buffer
34-
format: 'JPEG', // output format
35-
quality: 1 // the jpeg compression quality, between 0 and 1
43+
buffer: inputBuffer,
44+
format: 'JPEG',
45+
quality: 1
3646
});
3747

3848
await promisify(fs.writeFile)('./result.jpg', outputBuffer);
@@ -49,8 +59,8 @@ const convert = require('heic-convert');
4959
(async () => {
5060
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
5161
const outputBuffer = await convert({
52-
buffer: inputBuffer, // the HEIC file buffer
53-
format: 'PNG' // output format
62+
buffer: inputBuffer,
63+
format: 'PNG'
5464
});
5565

5666
await promisify(fs.writeFile)('./result.png', outputBuffer);
@@ -67,8 +77,8 @@ const convert = require('heic-convert');
6777
(async () => {
6878
const inputBuffer = await promisify(fs.readFile)('/path/to/my/image.heic');
6979
const images = await convert.all({
70-
buffer: inputBuffer, // the HEIC file buffer
71-
format: 'JPEG' // output format
80+
buffer: inputBuffer,
81+
format: 'JPEG'
7282
});
7383

7484
for (let idx in images) {

0 commit comments

Comments
 (0)