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

Explore/research MozJPEG #294

Closed
adamsilverstein opened this issue Apr 13, 2022 · 7 comments
Closed

Explore/research MozJPEG #294

adamsilverstein opened this issue Apr 13, 2022 · 7 comments
Labels
[Type] Enhancement A suggestion for improvement of an existing feature

Comments

@adamsilverstein
Copy link
Member

Feature Description

Contributors have pointed out that MozJPEG compression provides benefits over traditional JPEG compression without the potential compatibility issues WebP present.

The goal of this issue is to research MozJPEG further to evaluate its benefits and see how it can be used in WordPress.

Here are some initial questions to consider:

  • What do hosts need to do to make MozJPEG available on the server? (complex)
  • Is it (or can we make it) available by default in PHP GD?
  • Is MozJPEG compression detectable from image meta (if not stripped)?
  • How does it compare to WebP? - final file size at same dssim from original - level of effort (===energy) to compress/decompress.
  • Can/should we detect support in PHP and show a message in site health regarding support?
  • More generally it would be great to answer - how widespread is support for MozJPEG for WordPress? How many sites can already leverage MozJPEG?
@henrihelvetica
Copy link

MozJPEG, as in the encoder?? The only research I'm aware of are the ones that were associated w/ the original release announcement in 2014.

Dated, but maybe it helps.

@erikyo
Copy link

erikyo commented Apr 19, 2022

This is what I found on this topic:

What do hosts need to do to make MozJPEG available on the server? (complex)

Since MOZjpeg is a fork of the default encoder (jpeg-turbo) hosts need to build and install the encoder replacing the default one.

Is it (or can we make it) available by default in PHP GD?

Yes but we need to recompile PHP with MozJPEG instead of libjpeg

Is MozJPEG compression detectable from image meta (if not stripped)?

No, afaik isn't possible

How does it compare to WebP? - final file size at same dssim from original - level of effort (===energy) to compress/decompress.

Mozjpeg weighs 10% more than Webp at the same SSIM (source) and does not support alpha channel. However, it can be advantageous if the original is an already over-compressed jpg, it seems to degrade the original image less than the competitors, maybe because the same codec

Can/should we detect support in PHP and show a message in site health regarding support?

No, afaik isn't possible

More generally it would be great to answer - how widespread is support for MozJPEG for WordPress? How many sites can already leverage MozJPEG?

I think it's a very specific setup that few people currently have with php (whereas it is much easier with nodejs). I installed it but it is not currently working with Wordpress, I should replace cjpeg (system wide) but don't know if it's worth it, at least for the moment.

@mxbclang mxbclang added [Type] Enhancement A suggestion for improvement of an existing feature and removed [Type] Enhancement A suggestion for improvement of an existing feature labels May 5, 2022
@mxbclang mxbclang added [Type] Enhancement A suggestion for improvement of an existing feature no milestone PRs that do not have a defined milestone for release labels Jun 3, 2022
@bgoewert
Copy link

bgoewert commented Jun 6, 2022

Stumbled upon this issue after reading Is WebP Really Better Than JPEG? by @joppuyo, which compares JPEG, MozJPEG, WebP, and AVIF using the Kodak image dataset at different image sizes (500x, 100px, 1500px).

So, is WebP better than JPEG? It depends if you are using the reference libjpeg library or the improved MozJPEG encoder.

WebP seems to have about 10% better compression compared to libjpeg in most cases, except with 1500px images where the compression is about equal.

However, when compared to MozJPEG, WebP only performs better with small 500px images. With other image sizes the compression is equal or worse.

I think MozJPEG is the clear winner here with consistently about 10% better compression than libjpeg.

But as with most things, there were caveats with this test.

I only used photographic images.

I also tested the images in “Web quality” target of 85 so WebP may perform differently in very high or very low-quality settings.

Also, Google’s study used a different program to compute the SSIM values. In my tests, I used the dssim utility which computes multi-scale SSIM in LAB color space while the former seems to use simple SSIM in RGB color space.

@mxbclang mxbclang removed the no milestone PRs that do not have a defined milestone for release label Jun 22, 2022
@adamsilverstein
Copy link
Member Author

Yes but we need to recompile PHP mozilla/mozjpeg#345 instead of libjpeg

I wonder why this isn't enabled by default when available?

@joppuyo
Copy link

joppuyo commented Nov 15, 2022

Yes but we need to recompile PHP mozilla/mozjpeg#345 instead of libjpeg

I wonder why this isn't enabled by default when available?

Because libjpeg is the default JPEG library in most Linux distributions and other operating systems. If you wanna use MozJPEG, you will need to explicitly install it and recompile ImageMagick/GD using MozJPEG.

This is really an issue with the server environment and not the application code so WordPress can’t really influence what’s going on under the hood. It will simply use whatever JPEG library the server administrator has installed.

@adamsilverstein
Copy link
Member Author

Noting here that we should be able to achieve MozJPEG compression using client side image processing, maybe something to explore as part of that work.

@swissspidy
Copy link
Member

Noting here that we should be able to achieve MozJPEG compression using client side image processing, maybe something to explore as part of that work.

+1

The current solution (wasm-vips) uses MozJPEG under the hood already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants