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

Encounter unexpect result when extend static gif and covert to webp #2890

Closed
p4rksh opened this issue Sep 16, 2021 · 3 comments
Closed

Encounter unexpect result when extend static gif and covert to webp #2890

p4rksh opened this issue Sep 16, 2021 · 3 comments

Comments

@p4rksh
Copy link

p4rksh commented Sep 16, 2021

Hello :)

First, Thanks to provide awesome library!
I am using Sharp library to convert to webp or resize image.
But I detect a strange bug while using it.

108090882-7326952018020314993

sharp(body, { failOnError: false })
        .resize(600, 600)
        .webp({ quality })
        .toBuffer();

I was extending square static gif image to 600 x 600 and converting gif to webp. (I have no idea why this gif image is static. It is probably a user's mistake.)

스크린샷 2021-09-16 오전 11 18 38

I expected 600 x 600 webp, but I couldn't get. After testing it with various cases, an error occurs when trying to widen the width or height of static gif by multiple and convert it into webp.

Could you check it out?
Thanks :)

@p4rksh p4rksh added the triage label Sep 16, 2021
@lovell
Copy link
Owner

lovell commented Sep 16, 2021

Thanks for reporting this, I can reproduce it too. It's a bit of an edge case due to the output image height being a multiple of the "page height" of the non-animated input. The work-in-progress PR #2789 might address this, and a possible workaround for now is to manually set the pageHeight:

 sharp(body, { failOnError: false })
        .resize(600, 600)
-       .webp({ quality })
+       .webp({ quality, pageHeight: 600 })
        .toBuffer();

It could be worth fixing this in libvips too, so it removes page height metadata from non-animated GIF input, so I'll take a look to see if this is possible and/or makes sense.

@lovell lovell added bug and removed triage labels Sep 16, 2021
@p4rksh p4rksh changed the title Encounter unexpect result when extend static gif to webp Encounter unexpect result when extend static gif and covert to webp Sep 17, 2021
@p4rksh
Copy link
Author

p4rksh commented Oct 5, 2021

@lovell
Thanks to your appropriate answer, we were able to solve the problem.
Have a nice day :) 👍

@lovell lovell added this to the v0.29.2 milestone Oct 18, 2021
@lovell
Copy link
Owner

lovell commented Oct 21, 2021

v0.29.2 now available with the fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants