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

Problems converting CMYK to RGB with 6.9.11-19, regression? #83

Closed
neekfenwick opened this issue Jun 17, 2020 · 4 comments
Closed

Problems converting CMYK to RGB with 6.9.11-19, regression? #83

neekfenwick opened this issue Jun 17, 2020 · 4 comments

Comments

@neekfenwick
Copy link

Description

I have a PHP app that converts a CMYK JPG to sRGB for display on the web. As far as I can see this worked up until the end of May. I believe the result would include an 'icc' profile on the image, 'identify -vebose' of the output image would include a "Profile-icc" under "Profiles". For example, the latest image being converted has a grey/white coloured appearance and has a CMYK colour profile. When converted to sRGB it ought to display the same grey/white appearance, but instead displays as a blueish tinge.

Now, 'identify -verbose' of the output image does not include an 'icc' profile, and viewing the image (on the web or via gnome Image Viewer) the colours appear wrong, the same as opening the original CMYK image.

I have a long description at https://stackoverflow.com/questions/62421778/why-would-converting-cmyk-image-to-srgb-for-display-on-web-work-locally-but-not

Steps to Reproduce

(taken from the SO post above)

    $master_img = new Imagick();
    $master_img->readImage($master_filename_abs);

    $icc_profile_contents = file_get_contents($icc_profile_file);
    $l->log('About to profileImage()...');
    $r = $master_img->profileImage('icc', $icc_profile_contents);
    $l->log("profileImage returned $r " . ($r == TRUE ? 'true' : 'false'));

    $space = $master_img->getImageColorspace();
    $l->log("Colorspace starts as $space, CMYK is " . Imagick::COLORSPACE_CMYK);
    $r = $master_img->transformImageColorspace(imagick::COLORSPACE_SRGB);
    $l->log("transformImageColorspace returned $r " . ($r == TRUE ? 'true' : 'false'));
    $space = $master_img->getImageColorspace();
    $l->log("Colorspace after conversion is $space, SRGB is " . Imagick::COLORSPACE_SRGB);

    $master_img->scaleImage(800, 0);
    $l->log('Saving RGB profile version to ' . $preview_filename_abs);
    $master_img->writeImage($preview_filename_abs);

System Configuration

CentOS 7.3 production system
ImageMagick 6.9.11-19 Q16 x86_64 2020-06-15
(ImageMagick from the remi repo)

  • ImageMagick version: 6.9.11-19 (the latest available from remi repo)
  • Environment (Operating system, version and so on): CentOS 7.3
  • Additional information:
    I thought from the look of our yum logs that an upgrade from version 6.9.11.14-1 may have introduced the regression, however I have installed that old version (see https://forum.remirepo.net/viewtopic.php?pid=11207#p11207) and the colours still do not come out correctly.

Comparing 'identify -verbose' output for exactly the same image file produces different output with 6.9.11.14 and 6.9.11.19:

$ diff so_prod_6.9.11.14 so_prod
84,85d83
<   Profiles:
<     Profile-icc: 557168 bytes
89,90d86
<     icc:copyright: Copyright 2000 Adobe Systems, Inc.
<     icc:description: U.S. Web Coated (SWOP) v2
100,103c96,99
<   Pixels per second: 29.4645MB
<   User time: 0.020u
<   Elapsed time: 0:01.008
<   Version: ImageMagick 6.9.11-14 Q16 x86_64 2020-05-25 https://imagemagick.org
---
>   Pixels per second: 27.3785MB
>   User time: 0.010u
>   Elapsed time: 0:01.009
>   Version: ImageMagick 6.9.11-19 Q16 x86_64 2020-06-15 https://imagemagick.org

I don't see why the older 'identify' tool reports an icc profile, and the newer one does not, for the same JPG file (SO.jpg, attached here and also attached to the above mentioned Stack Overflow topic).
SO

I am far from expert in this subject so I think adding any more attempts would muddy the water!

@neekfenwick
Copy link
Author

Aside from my confusion with the PHP binding, which I still can't get to behave, I think I can show a problem with just the command line tools.

A little testing to demonstrate 6.9.11.14 vs 6.9.11.19, in each case I do the same conversions, 1/ just with -colorspace and 2/ with -profile and -colorspace:

Install 6.9.11.14:
$ convert src.jpg -colorspace srgb src_srgb_noprofile-6.9.11.14.jpg
$ convert src.jpg -profile AdobeRGB1998.icc -colorspace srgb src_srgb_withprofile-6.9.11.14.jpg

Install 6.9.11.19:
$ convert src.jpg -colorspace srgb src_srgb_noprofile-6.9.11.19.jpg
$ convert src.jpg-profile AdobeRGB1998.icc -colorspace srgb src_srgb_noprofile-6.9.11.19.jpg

Attached files:
Original src.jpg image..
src
Produced by 6.9.11.14 with just -colorspace:
src_srgb_noprofile-6 9 11 14
Produced by 6.9.11.14 with -profile and -colorspace:
src_srgb_withprofile-6 9 11 14
Produced by 6.9.11.19 with just -colorspace:
src_srgb_noprofile-6 9 11 19
Produced by 6.9.11.19 with -profile and -colorspace:
src_srgb_withprofile-6 9 11 19

all_results_side_by_side
This last one shows the only one that looks "right" with the grey/white colours is the one produced by 6.9.11.14. Both files produced by 6.9.11.19 show incorrect colours.

@urban-warrior
Copy link
Member

Thanks for the problem report. We can reproduce it and will have a patch to fix it in the GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

urban-warrior pushed a commit to ImageMagick/ImageMagick that referenced this issue Jun 22, 2020
@neekfenwick
Copy link
Author

neekfenwick commented Jun 24, 2020

I can confirm that building ImageMagick-6.9.11-22_beta20200623.tar.gz from source seems to show the issue as fixed.

$ ./configure --without-magick-plus-plus --with-jpeg --with-lcms
$ make -j4
$ ./utilities/convert src.jpg -profile AdobeRGB1998.icc -colorspace srgb src_srgb_withprofile_6.9.11-22.jpg

identify reports the image has an icc profile and it displays well in nautilus. Thank you!

@dlemstra
Copy link
Member

And thank you for reporting this 👍

@dlemstra dlemstra closed this as completed Jul 4, 2020
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jul 29, 2020
Clean up pkglint while here.

2020-07-18  7.0.10-24  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-24 GIT revision 17483:d11a2ec03:20200718

2020-07-18  7.0.10-24 Dirk Lemstra <dirk@lem.....org>
  * To preserve compression of input image with the tiff encoder use:
    -define tiff:preserve-compression=true.

2020-07-05  7.0.10-24  <quetzlzacatenango@image...>
  * Add support for the -white-balance command-line option.
  * Discover hidden files when globbing (e.g. *.jpg) (reference
    ImageMagick/ImageMagick#2239).
  * New inverse-log evaluate operator.

2020-07-04  7.0.10-23  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-23 GIT revision 17437:894231bc3:20200704

2020-06-28  7.0.10-23  <quetzlzacatenango@image...>
  * Ensure that float is valid in ClampToQuantum() (reference
    ImageMagick/ImageMagick#2219).
  * New pseudo-image format, ashlar, e.g.
    convert *.jpg -resize 320x320 ashlar:canvas.png).

2020-06-27  7.0.10-22  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-22 GIT revision 17415:5318a3e0a:20200627

2020-06-24  7.0.10-22  <quetzlzacatenango@image...>
  * Fix wrapping of caption (reference
    ImageMagick/ImageMagick#2178).
  * Sanity check of affine matrix when drawing.

2020-06-22  7.0.10-21  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-21 GIT revision 17395:af81c28c9:20200622

2020-06-21  7.0.10-21  <quetzlzacatenango@image...>
  * New image property, %N, only report the # of frames in an image sequence,
    just once rather than on a per frame basis
  * Problems converting CMYK to RGB regression (reference
    ImageMagick/ImageMagick6#83)

2020-06-21  7.0.10-21 Dirk Lemstra <dirk@lem.....org>
  * Added support for 32 bit zip with prediction format to the PSD decoder
    (reference ImageMagick/ImageMagick#455).

2020-06-20  7.0.10-20  <quetzlzacatenango@image...>
  * Release ImageMagick version 7.0.10-20 GIT revision 17372:d91c43f3b:20200620

2020-06-14  7.0.10-20  <quetzlzacatenango@image...>
  * Fix out-of-bounds vulnerability when reading sixel images (reference
    ImageMagick/ImageMagick#2143).
  * Fix incorrect parsing of font family list (reference
    ImageMagick/ImageMagick#2153).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants