Skip to content

Commit

Permalink
Do not use MozJPEG progressive default
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 31, 2024
1 parent 350febf commit 7733640
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ def test_progressive(self) -> None:
assert not im2.info.get("progressive")
assert im3.info.get("progressive")

assert_image_equal(im1, im3)
if features.check_feature("mozjpeg"):
assert_image_similar(im1, im3, 9.39)
else:
assert_image_equal(im1, im3)
assert im1_bytes >= im3_bytes

def test_progressive_large_buffer(self, tmp_path: Path) -> None:
Expand Down
7 changes: 7 additions & 0 deletions src/libImaging/JpegEncode.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
}

/* Compressor configuration */
#ifdef JPEG_C_PARAM_SUPPORTED
// MozJPEG
if (!context->progressive) {
// Do not use MozJPEG progressive default
jpeg_c_set_int_param(&context->cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
}
#endif
jpeg_set_defaults(&context->cinfo);

/* Prevent RGB -> YCbCr conversion */
Expand Down

0 comments on commit 7733640

Please sign in to comment.