-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Add support for libwebp 'target_size' parameter #3824
Comments
I can try and get an MVP for this change. It doesn't look too hard, but my C/C++ is pretty bad. Will probably need a bit of help pushing the final bit through. |
Sure, happy to help. |
I created a pull request. Turns out to work just fine once you realize that the |
@jcupitt Don't want to be a nuisance, but did you see this? I'd love to hear your opinion. |
Sorry @john-parton, I reviewed now. |
Thanks so much! I'll continue our discussion over there. No need to apologize; I'm just excited to get something going! |
Discussed in #3822
Originally posted by john-parton January 20, 2024
The webp API supports saving with a "target_size" parameter to limit the maximum size of the resulting file.
https://developers.google.com/speed/webp/docs/api
As far as I can tell, this isn't exposed in libvips (and consequently pyvips, the binding I am using.)
This is a useful feature for my use case. I preprocess images before they are sent to CloudFlare Images. They have specific limits for resolution, but also an overall limit for file size. In my case, I set images to be at most 6,000 x 6,000 pixels and am saving with Q=90. For the vast majority of images, that's fine, because the resulting image is usually significantly less than 10MB, but for some noisy images with difficult to compress features, it just barely goes over the 10MB boundary.
If I could just pass this in, I wouldn't have to worry about, but now I'm faced with having to either:
I wouldn't really consider either of these to be a good solution.
The text was updated successfully, but these errors were encountered: