From d58327650ae188dd1a9b0e8827907ae4bc39dafe Mon Sep 17 00:00:00 2001 From: Kiril Vatev Date: Wed, 8 Nov 2023 11:21:59 -0500 Subject: [PATCH] simplifying code example --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 97a3ef8..b7e6aca 100644 --- a/README.md +++ b/README.md @@ -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); ```