You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
My goal is to extract frames from an animated WebP file. However, a 'bad extract area' error occurs when calling toBuffer() in the second loop.
async function decodeAwebp(buffer) {
const webpImage = sharp(buffer, { animated: true, pages: -1 });
const metadata = await webpImage.metadata();
const { pages, width, height, pageHeight, delay } = metadata;
if (!pages || pages < 2) {
throw new Error('This WebP image is not animated.');
}
const frames = [];
for (let i = 0; i < pages; i++) {
const frame = image
.extract({ left: 0, top: pageHeight * i, width, height: pageHeight })
.ensureAlpha()
.raw()
.toBuffer();
frames.push(frame);
}
return {
width,
pageHeight,
delay,
frames
};
}
Problem:
The code runs without issue for the first frame, but when it reaches the second loop, I encounter a bad extract area error during the toBuffer() call.
Is there an issue with my code, or is this a potential bug in the Sharp library? Any guidance or assistance would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
Sharp Version: 0.32.1
Description:
My goal is to extract frames from an animated WebP file. However, a 'bad extract area' error occurs when calling toBuffer() in the second loop.
Sample image
https://cafe24img.poxo.com/benitomaster/web/product/small/202404/e45078df2e402a9b4a9e48bfc08b0b0e.webp
Problem:
The code runs without issue for the first frame, but when it reaches the second loop, I encounter a bad extract area error during the toBuffer() call.
Is there an issue with my code, or is this a potential bug in the Sharp library? Any guidance or assistance would be greatly appreciated.
The text was updated successfully, but these errors were encountered: