Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing an animated WebP throws and error vips2webp: unable to encode #2501

Closed
metju opened this issue Dec 29, 2020 · 3 comments
Closed

Resizing an animated WebP throws and error vips2webp: unable to encode #2501

metju opened this issue Dec 29, 2020 · 3 comments
Labels

Comments

@metju
Copy link

metju commented Dec 29, 2020

I'm trying to resize some files, but it starts failing very soon. Might be hitting some WebP file dimension limit? I've noticed when dealing with animated gifs, it loads all the pages into one tall file when processing.


sharp('animated-webp-supported.webp', {animated: true})
	.resize(2880)
	.webp()
	.toFile('resized.webp')

the file I'm trying to convert (zipped, since GitHub doesn't like WebPs)

@metju metju added the triage label Dec 29, 2020
@lovell
Copy link
Owner

lovell commented Dec 30, 2020

Hi, given you're resizing, you'll need to update the pageHeight, in this 12-page example to 2880 / 12 = 240.

-  .webp()
+  .webp({ pageHeight: 240 })

https://sharp.pixelplumbing.com/api-output#webp

See also #2275 for a future possible improvement relating to this.

@lovell lovell added question and removed triage labels Dec 30, 2020
@metju
Copy link
Author

metju commented Dec 31, 2020

Hello, thanks for the response!

240 didn't work, but 2880 did (it's the new height of the resized image, right?). I've tried setting the pageHeight before asking, but I didn't guess the right value.

Is it possible to get the new exact height of a resized image? If not, and I have to calculate it myself, should I floor, ceil or round the value? I've tried the conversion with 2879 and 2881 and both didn't work, so this seems important to get right.

When setting the pageHeight, are there more than one correct value, that wouldn't produce the unable to encode error? Could then sharp do this work for us and calculate it?

@lovell
Copy link
Owner

lovell commented Dec 31, 2020

I confused width and height in my answer, apologies. Glad you got it working. Please see #2275 for a future possible improvement relating to this.

@lovell lovell closed this as completed Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants