Closed jzarca01 closed 4 years ago
Hmm... based on where in the code that throws, it looks like you may not be passing in a buffer? Do you have the code that you used to run into this?
I don't think I did anything wrong, here's my code
async function init() {
try {
const inputBuffer = await promisify(fs.readFile)("cat.heic");
const images = await convert({ inputBuffer, format: "JPEG" });
for (let idx in images) {
const image = images[idx];
const outputBuffer = await image.convert();
await promisify(fs.writeFile)(`./result-${idx}.jpg`, outputBuffer);
}
} catch (err) {
console.log(err);
}
}
The property is named buffer
and you are providing inputBuffer
to the convert
function. Try doing
await convert({ buffer: inputBuffer, format: "JPEG" });
You're right, my bad
Now the error seems to be TypeError: image.convert is not a function
I just noticed that my example code had all sorts of issues. That's what I get for writing code directly into the readme late at night. Take a look at it now, it should be all better.
It's essentially the same API as the heic-decode
example you fixed earlier. Call convert
to do a single image and convert.all
to get all images.
Thanks a lot @catdad !!!
With a multiple image heic