-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support for saving lossless WebP #408
Conversation
e2582ee
to
52b18a2
Compare
This is a great start, thanks Dennis, the proposed API looks good and your todo list is sensible. You'll be pleased to know I'm currently working on libvips v8.3.0-pre binaries for the CI environments to use, including the addition of WebP support on Windows. |
082ca6e
to
5b0f2d6
Compare
@dhotson There's more nice stuff coming for WebP in jcupitt/libvips#430. One of the features added in that PR is near lossless encoding, which applies filtering to the image to improve compression. With moderate filtering you can likely reach ~50% of PNG24 filesize. Another interesting one is the I tested several compression settings on the 600x600 RGBA sample image linked in the PR above:
The comparison only show PNG24 vs. WebP Lossy vs. WebP Lossy with smart subsample, which looks just as good as the PNG to me, while the normal lossy image looks poor even with quality 100%. |
@felixbuenemann nice work! Should I close this PR? Does your PR include lossless webp as an option? |
@dhotson Please don't close this. I was talking about a libvips PR not sharp. |
Ah oops! I thought that linked PR was this repo. Reopening.. :) |
c1df4ae
to
7388d97
Compare
52b18a2
to
289aac9
Compare
The Let me know when you're ready to continue with this and we can work out the most suitable destination branch at the time. |
Oh, looks like Github auto-closed this PR when I removed the outfit branch. |
Ah no problem—is this still something that you're interested in? I'm not sure where it stands alongside some of the other things that @felixbuenemann mentioned. |
Yes, I'm still interested in exposing WebP |
Oddly, lossy webP on a 12kb image is resulting in a 21kb final image, whereas losseless is giving me a 5kb image at better quality? |
Hello. :)
This PR adds initial support for saving lossless WebP.
Sharp usually saves WebP in lossy mode with a default quality of 80.
A bug that was fixed in libvips 8.3 means lossless WebP output is now possible.
To enable this in sharp, I've introduced an options object parameter to the webp method. e.g.
I'd be happy to make changes to the API—please just let me know.
Also, I haven't added test cases since my test environment isn't working quite right. Once I've got that worked out—any thoughts on the kinds of tests you would like to see?
Todo
toFormat()
and other methods?Example image output
PNG (lossless)
WebP (lossy - quality:80)
WebP (lossless)