Color shift with no operations

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ericmwilliams
Posts: 4
Joined: 2019-05-01T09:36:33-07:00
Authentication code: 1152

Color shift with no operations

Post by ericmwilliams »

I'm troubleshooting an issue with color shift that is resistant to all my efforts at solving it.

After eliminating all other causes, I have a color shift that happens when simply reading in an image and outputting it into a new file:

/usr/bin/convert theFile.png theFile-output.png

Colors in the output file are shifted slightly - a medium blue went a few shades darker, for example. My guess is that the embedded color profile is being ignored.

Here is the 'identify -verbose' output for the SOURCE file:

Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1375x671+0+0
Resolution: 28.35x28.35
Print size: 48.5009x23.6684
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
(--channel stat data omitted--)
Colors: 484
Histogram:
(--historgram data omitted--)
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 1375x671+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2019-04-30T17:57:21-04:00
date:modify: 2019-04-30T17:57:13-04:00
png:iCCP : chunk was found
png:IHDR.bit_depth : 8
png:IHDR.color_type : 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height : 1375, 671
png:pHYs : x_res=2835, y_res=2835, units=1
signature: 901056e6658954bfc16038fe51fc4c89b1fd3637d7c31fa4bf189a5ed4a3e939
Profiles:
Profile-icc: 2008 bytes
Description: Generic RGB Profile
Manufacturer: Generic RGB Profile
Model: Generic RGB Profile
Copyright: Copyright 2007 Apple Inc., all rights reserved.
Artifacts:
filename: /exports/gfs/sites/reskin.mavericklabel.com/htdocs/../htdocs/proofs/upload/CM191-080-065proof-2540.png
verbose: true
Tainted: False
Filesize: 22.5KB
Number pixels: 923K
Pixels per second: 23.07MB
User time: 0.040u
Elapsed time: 0:01.040
Version: ImageMagick 6.7.8-9 2019-04-30 Q16 http://www.imagemagick.org


And here is the 'identify -verbose' for the OUTPUT file:

Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1375x671+0+0
Resolution: 28.35x28.35
Print size: 48.5009x23.6684
Units: PixelsPerCentimeter
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
(--channel stat data omitted--)
Colors: 484
Histogram:
(--historgram data omitted--)
Rendering intent: Perceptual
Gamma: 0.45455
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 1375x671+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2019-05-01T12:27:38-04:00
date:modify: 2019-05-01T12:27:38-04:00
png:bKGD : chunk was found (see Background color, above)
png:cHRM : chunk was found (see Chromaticity, above)
png:gAMA : gamma=0.45454544 (See Gamma, above)
png:IHDR.bit_depth : 8
png:IHDR.color_type : 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height : 1375, 671
png:pHYs : x_res=2835, y_res=2835, units=1
png:sRGB : intent=0 (Perceptual Intent)
png:text : 2 tEXt/zTXt/iTXt chunks were found
signature: 901056e6658954bfc16038fe51fc4c89b1fd3637d7c31fa4bf189a5ed4a3e939
Artifacts:
filename: /exports/gfs/sites/reskin.mavericklabel.com/htdocs/../htdocs/proofs/upload/CM191-080-065proof-2540-output.png
verbose: true
Tainted: False
Filesize: 10.3KB
Number pixels: 923K
Pixels per second: 23.07MB
User time: 0.050u
Elapsed time: 0:01.040
Version: ImageMagick 6.7.8-9 2019-04-30 Q16 http://www.imagemagick.org

Note that the output file has no embedded color profile.

Thanks for any notions you may have.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color shift with no operations

Post by fmw42 »

Your image has a generic RGB profile. PNG requires the use of sRGB profile. That could be causing the shift as your profile will be replace with the sRGB one built internal to PNG or you could convert by adding -profile sRGB.icc to convert your profile to the needed sRGB one.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color shift with no operations

Post by snibgo »

As Fred says, the colour shift is probably due to the profile being stripped.

The command shown in the OP should not strip the profile, and recent versions of IM don't.
ericmwilliams wrote:Version: ImageMagick 6.7.8-9
I suggest you upgrade to a more recent version.
snibgo's IM pages: im.snibgo.com
ericmwilliams
Posts: 4
Joined: 2019-05-01T09:36:33-07:00
Authentication code: 1152

Re: Color shift with no operations

Post by ericmwilliams »

Curiously, an older version (6.7.2-7 2016-06-16) does NOT have this problem.

We'll look at upgrading...
ericmwilliams
Posts: 4
Joined: 2019-05-01T09:36:33-07:00
Authentication code: 1152

Re: Color shift with no operations

Post by ericmwilliams »

fmw42 wrote: 2019-05-01T14:25:43-07:00 Your image has a generic RGB profile. PNG requires the use of sRGB profile.
That's not true. The PNG format has full support for embedded color profiles and the color spaces defined by them. Now, applications may or may not support those color profiles, but the format itself is not restricted to sRGB.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color shift with no operations

Post by snibgo »

Yes, PNG can support any RGB profile. It doesn't need to be sRGB, eg it could be AdobeRGB. IM can assign such profiles, convert to/from them, or simply copy them from input to output. In the OP command, the profile should copied.

I assume that command didn't give an error message saying the profile was invalid. I expect an invalid (eg corrupt) profile won't be copied.
snibgo's IM pages: im.snibgo.com
ericmwilliams
Posts: 4
Joined: 2019-05-01T09:36:33-07:00
Authentication code: 1152

Re: Color shift with no operations

Post by ericmwilliams »

Yeah, no errors reported.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color shift with no operations

Post by snibgo »

If you paste a link to the file, we can test it with recent versions of IM. (But it's past my bedtime, so tomorrow.)
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color shift with no operations

Post by fmw42 »

ericmwilliams wrote: 2019-05-01T15:42:16-07:00
fmw42 wrote: 2019-05-01T14:25:43-07:00 Your image has a generic RGB profile. PNG requires the use of sRGB profile.
That's not true. The PNG format has full support for embedded color profiles and the color spaces defined by them. Now, applications may or may not support those color profiles, but the format itself is not restricted to sRGB.

My mistake. I realized that some time later when I was out and could not edit my post. But his profile is being lost/eliminated and needs to be put back or converted to sRGB.
Post Reply