-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plug-ins: new JPEG export option to value file size over encoding speed.
This uses MozJPEG from Mozilla and is dependent on this patch to be merged: mozilla/mozjpeg#383 This is an optional option (standard libjpeg API, e.g. with jpeg-turbo, is still used when MozJPEG is not detected at build time). When using MozJPEG, we have access to both the standard algorithm used by libjpeg-turbo, since MozJPEG is a patched version of libjpeg-turbo, and their own encoding algorithm. We can switch from one to another with a single call. Here is what the maintainer says about MozJPEG goal: > The point of MozJPEG is to improve quality/filesize ratio. It's a win-win: you > get better quality for the same file size, or better file size for the same > quality, or both. There is no downside in either quality or file size. MozJPEG > tunes for these two aspects over speed. libjpeg-turbo's maintainer values speed > over the other two variables. > > MozJPEG has a few techniques. Improved splitting of progressive scans gives > smaller file size while being 100% visually identical with libjpeg-turbo. > > But MozJPEG also has trellis quantization and tuned quantization tables that > give better visual quality, but on a microscopic scale they make different > choices than libjpeg-turbo, so some pixels differ. The differences are > relatively small and predictable, so there's no risk of unexpectedly ruining > an image (especially that on average, you get better quality). Cf. mozilla/mozjpeg#382 (comment) Note that after several testing, I could indeed confirm that it seems to always produce smaller files (as far as my testing went) for similarly looking quality, but the speed cost can actually be quite important: on my computer, for some random files where encoding would take 0.7 second, it took 3.5 secs with mozjpeg; for much bigger file (~25MiB) where export with jpeg-turbo takes about 3.9 secs, it takes 30+ seconds with MozJPEG which is a huge difference and can be very frustrating. For small files only, this is less of a problem (I still timed an important difference, but from 0.05 to 0.15 secs is actually bearable). This is why this cannot be an option checked by default. About naming: I hesitated to call it "Export for Web" because it's clearly one of the big use cases (optimizing file size for images on websites), but I just decided to go with a much more explicit name (even though it may resonate less that the basic "Export for Web" which everyone asks for).
- Loading branch information
Jehan
committed
Sep 7, 2023
1 parent
5e399eb
commit 9ff73dc
Showing
5 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters