Skip to content

Commit

Permalink
simplifying code example
Browse files Browse the repository at this point in the history
  • Loading branch information
catdad committed Nov 8, 2023
1 parent f854a3a commit d583276
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,18 @@ In NodeJS, you might use this decoded data with other libraries, such as `pngjs`
```js
const { PNG } = require('pngjs');

const arrayBuffer = await new Promise((resolve, reject) => {
const imageData = await new Promise((resolve, reject) => {
image.display({ data: new Uint8ClampedArray(width*height*4), width, height }, (displayData) => {
if (!displayData) {
return reject(new Error('HEIF processing error'));
}

resolve(displayData.data.buffer);
resolve(displayData);
});
});

const imageData = { width, height, data: arrayBuffer };

const png = new PNG({ width: imageData.width, height: imageData.height });
png.data = Buffer.from(imageData.data);
png.data = imageData.data;

const pngBuffer = PNG.sync.write(png);
```
Expand Down

0 comments on commit d583276

Please sign in to comment.