Skip to content

Commit d583276

Browse files
committed
simplifying code example
1 parent f854a3a commit d583276

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,18 @@ In NodeJS, you might use this decoded data with other libraries, such as `pngjs`
7878
```js
7979
const { PNG } = require('pngjs');
8080

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

87-
resolve(displayData.data.buffer);
87+
resolve(displayData);
8888
});
8989
});
9090

91-
const imageData = { width, height, data: arrayBuffer };
92-
9391
const png = new PNG({ width: imageData.width, height: imageData.height });
94-
png.data = Buffer.from(imageData.data);
92+
png.data = imageData.data;
9593

9694
const pngBuffer = PNG.sync.write(png);
9795
```

0 commit comments

Comments
 (0)