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

Jpegoptim changes ImageMagick rgb decode of a few images #77

Open
dreamlayers opened this issue Apr 5, 2021 · 3 comments
Open

Jpegoptim changes ImageMagick rgb decode of a few images #77

dreamlayers opened this issue Apr 5, 2021 · 3 comments

Comments

@dreamlayers
Copy link

In the past I verified that jpegoptim does not alter images by doing an ImageMagick convert rgb decode before and after, and then comparing md5 sums. Right now I'm finding that some images are altered. I'm attaching one here: P7010105 A quick glance through cmp -l output shows that many pixel values are changed by 1. (Example JPEG file MD5 is be84d44f1c409d570e40e5a84571c3be, and I've verified that GitHub didn't alter it.)

This problem is present with v1.4.4 which I built myself, v1.4.6 which is available in Ubuntu 21.04 and v1.4.7beta which I just built from git source. I'm using convert "$i" "$i.rgb" with "ImageMagick 6.9.10-23 Q16 x86_64 20190101" which is part of Ubuntu 21.04. All of this is in Ubuntu 21.04, on two different x86_64 systems.

This happens both with normal and progressive (interlaced) output.

@dreamlayers
Copy link
Author

I have the same issue in Windows 10 with Ubuntu 20.04.2 LTS running under WSL1. It has jpegoptim v1.4.6 and ImageMagick 6.9.10-23 Q16 x86_64 20190101. The problem also happens with that file when I use my old jpegoptim v1.4.4beta built using Cygwin i686-w64-mingw32 in Windows.

@dreamlayers
Copy link
Author

The output of djpeg from libjpeg-turbo version 2.0.6 (build 20210328) is not changed by jpegoptim for these same images. Why do djpeg and convert act differently?

Simply running jhead -purejpg (without using jpegoptim) on the images doesn't change ImageMagick rgb output. Also, after that jpegoptim also changes ImageMagick rgb output. So it's not some header thing like a colour profile.

@tjko
Copy link
Owner

tjko commented Apr 5, 2022

I would guess this has something to do with the JPEG library that jpegoptim was compiled against... (seen weird behavior with libjpeg-turbo in the past...)

I tested with latest (compiled from git) and wasn't able to reproduce your issue:

$ cp original.jpg test.jpg
$ ./jpegoptim test.jpg
test.jpg 2288x1520 24bit N Exif  [OK] 680763 --> 670108 bytes (1.57%), optimized.
$ gm compare -metric mse original.jpg test.jpg 
Image Difference (MeanSquaredError):
           Normalized    Absolute
          ============  ==========
     Red: 0.0000000000        0.0
   Green: 0.0000000000        0.0
    Blue: 0.0000000000        0.0
   Total: 0.0000000000        0.0

Tried also converting to progressive JPEG (that usually yields slightly smaller output files):

$ ./jpegoptim --all-progressive test.jpg 
test.jpg 2288x1520 24bit N Exif JFIF  [OK] 670108 --> 638980 bytes (4.65%), optimized.
$ gm compare -metric mse original.jpg test.jpg 
Image Difference (MeanSquaredError):
           Normalized    Absolute
          ============  ==========
     Red: 0.0000000000        0.0
   Green: 0.0000000000        0.0
    Blue: 0.0000000000        0.0
   Total: 0.0000000000        0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants