-
-
Notifications
You must be signed in to change notification settings - Fork 666
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
mozjpeg experiments #1422
Comments
Thanks @jcupitt for putting all tests together. I am using this Dockerfile. Do you think that system jpeg might be used by libvips in any way? https://gist.github.com/adityapatadia/ee2312f92dd60aee741e2f9e71965b94 |
I don't think so, but I'm just trying it now, hang on. |
My question is that when I use mozjpeg through NodeJS Sharp library which uses libvips, the encoding is much faster but when I use mozjpeg through https://github.com/danielgtaylor/jpeg-archive the speed is less. Is there a possibility that these lines in mozjpeg are disabled when JCP_FASTEST flag is set by vips here? |
I made a dockerfile based on yours that runs those tests and I see the same results: https://github.com/jcupitt/docker-builds/tree/master/libvips-mozjpeg-buster
So I think your dockerfile is working correctly. |
(I made it use the latest mozjpeg and libvips, and I removed the libwebp build for clarity) |
My understanding is that:
Just sets the compression defaults. A few lines below, libvips enables trellis / quant / optim / etc. if those options have been set. Perhaps libvips should have an option for |
I tried swapping FASTEST for MAX and I see:
So up to about 20% saving now, nice! With FASTEST, it's:
So perhaps 3x slower encoding. |
Awesome! |
Exactly my thoughts. Just setting those options is not same as setting MAX. We are not utilising full potential of mozjpeg I think. |
I have very limited knowledge of C so it would be hard for me to create a PR but let me know whatever way I can help you. Let me know your thoughts about how do you plan to get this resolved. |
Hey @lovell, sorry to ping you, what do you think about adding a It would simply turn on all the mozjpeg options that improve compression ratio. It looks like it might get us another 10% or so, though at a pretty high CPU cost. |
Oh, don't worry about a PR, it's only ~10 lines of code. |
turns all mozjpeg compression options on, if possible see #1422
... I made a PR for testing. |
Setting libvips' existing |
Oh yes, I'd forgotten about
So no need for
Thanks! |
I tried |
Thanks @lovell for pointing out. I think then those DC and AC filters will have very small effect on final image size. @jcupitt does it affect quality in any way or quality also remains same? If the quality remains same, we can close this issue after putting this in some documentation. |
You'll get an image that looks slightly different, but it would be up to you to decide if it was better or worse. I'd do some experiments. I'll add a note to the docs. Thank you everyone for this! |
Thanks John for super quick benchmarks on this. |
jcupitt explains the mozjpeg parameters in this comment: libvips/libvips#1422 (comment) Additionally, look for references to mozjpeg in the documentation for vips_jpegsave(): https://libvips.github.io/libvips/API/current/VipsForeignSave.html#VipsForeignJpegSubsample These changes improved jpeg compression for my test image, especially with the addition of overshoot_deringing when compresses a screenshot that includes text.
jcupitt explains the mozjpeg parameters in this comment: libvips/libvips#1422 (comment) Additionally, look for references to mozjpeg in the documentation for vips_jpegsave(): https://libvips.github.io/libvips/API/current/VipsForeignSave.html#VipsForeignJpegSubsample These changes improved jpeg compression for my test image, especially with the addition of overshoot_deringing when compressing a screenshot that includes text.
jcupitt explains the mozjpeg parameters in this comment: libvips/libvips#1422 (comment) Additionally, look for references to mozjpeg in the documentation for vips_jpegsave(): https://libvips.github.io/libvips/API/current/VipsForeignSave.html#VipsForeignJpegSubsample These changes improved jpeg compression for my test image, especially with the addition of overshoot_deringing when compressing a screenshot that includes text.
In this twitter thread:
https://twitter.com/adityapatadia/status/1171376632419901440
Aditya Patadia wonders about mozjpeg speed and compression. I thought I'd open an issue to discuss this.
I made a dockerfile to show how to use libvips with mozjpeg:
https://github.com/jcupitt/docker-builds/tree/master/libvips-mozjpeg-ubuntu18.10
Running that test script, I see:
(libjpeg-turbo in this case): 516331 and 518535 bytes.
optimize-scans
adds about 20% to runtime and saves 3kb.trellis-quant
also adds about 20% to runtime and saves 46kb (10%).overshoot-deringing
is free and does not affect filesize.The text was updated successfully, but these errors were encountered: