Colors change in TIF to PNG conversion

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
thobbs
Posts: 3
Joined: 2014-11-29T10:44:53-07:00
Authentication code: 6789

Colors change in TIF to PNG conversion

Post by thobbs »

I'm trying to convert a TIFF image that was created with Processing to PNG, but the colors are coming out more saturated in the PNG version in some viewers.

The colors look correct when viewed with the following applications: GIMP, Shotwell (Ubuntu), Chrome (Ubuntu), and Safari on an iPhone
They are incorrect when viewed with: Firefox (on Ubuntu or OSX), Safari on OSX, or the "Image Viewer" program on Ubuntu

You can find the TIF here: http://www.tylerlhobbs.com/static/img/i ... /image.tif
And the PNG here: http://www.tylerlhobbs.com/static/img/i ... /image.png

This is my ImagMagick version:

Code: Select all

Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Because the colors appear correct in some viewers, I'm guess that some color information is missing or incorrect in the color profile for the image, but I'm not sure. I have tried using -colorspace sRGB when converting to PNG to no avail. I have also tried adjusting the gamma on the PNG image, which gets it closer to the correct colors, but the result is still too saturated.

Here's the info for the TIF image:

Code: Select all

Image: image.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 800x800+0+0
  Resolution: 72x72
  Print size: 11.1111x11.1111
  Units: PixelsPerInch
  Type: TrueColor
  Base type: TrueColor
  Endianess: MSB
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 22 (0.0862745)
      max: 252 (0.988235)
      mean: 91.6865 (0.359555)
      standard deviation: 44.3927 (0.174089)
      kurtosis: 3.84851
      skewness: 1.80316
    Green:
      min: 17 (0.0666667)
      max: 229 (0.898039)
      mean: 159.566 (0.62575)
      standard deviation: 49.9514 (0.195888)
      kurtosis: 0.635568
      skewness: -1.39959
    Blue:
      min: 32 (0.12549)
      max: 224 (0.878431)
      mean: 129.089 (0.506232)
      standard deviation: 39.188 (0.153678)
      kurtosis: 0.912725
      skewness: -0.730359
  Image statistics:
    Overall:
      min: 17 (0.0666667)
      max: 252 (0.988235)
      mean: 126.781 (0.497179)
      standard deviation: 44.7272 (0.175401)
      kurtosis: 0.865417
      skewness: -0.0746656
  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: 800x800+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Properties:
    date:create: 2014-11-29T11:41:35-06:00
    date:modify: 2014-11-29T11:41:35-06:00
    signature: ea07b01b2f85f739959103743e0ef83520e174489b952ffc18c495a049c68581
    tiff:document: image.tif
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 3
  Artifacts:
    filename: image.tif
    verbose: true
  Tainted: False
  Filesize: 1.256MB
  Number pixels: 640K
  Pixels per second: 21.33MB
  User time: 0.030u
  Elapsed time: 0:01.030
  Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
And the info for the PNG image:

Code: Select all

Image: image.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 800x800+0+0
  Resolution: 28.34x28.34
  Print size: 28.2287x28.2287
  Units: PixelsPerCentimeter
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Red:
      min: 22 (0.0862745)
      max: 252 (0.988235)
      mean: 91.6865 (0.359555)
      standard deviation: 44.3927 (0.174089)
      kurtosis: 3.84851
      skewness: 1.80316
    Green:
      min: 17 (0.0666667)
      max: 229 (0.898039)
      mean: 159.566 (0.62575)
      standard deviation: 49.9514 (0.195888)
      kurtosis: 0.635568
      skewness: -1.39959
    Blue:
      min: 32 (0.12549)
      max: 224 (0.878431)
      mean: 129.089 (0.506232)
      standard deviation: 39.188 (0.153678)
      kurtosis: 0.912725
      skewness: -0.730359
  Image statistics:
    Overall:
      min: 17 (0.0666667)
      max: 252 (0.988235)
      mean: 126.781 (0.497179)
      standard deviation: 44.7272 (0.175401)
      kurtosis: 0.865417
      skewness: -0.0746656
  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: 800x800+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2014-11-29T11:41:49-06:00
    date:modify: 2014-11-29T11:41:49-06: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    : 800, 800
    png:pHYs                 : x_res=2834, y_res=2834, units=1
    png:sRGB                 : intent=0 (See Rendering intent)
    png:text                 : 6 tEXt/zTXt/iTXt chunks were found
    signature: ea07b01b2f85f739959103743e0ef83520e174489b952ffc18c495a049c68581
    tiff:document: image.tif
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 3
  Artifacts:
    filename: image.png
    verbose: true
  Tainted: False
  Filesize: 946KB
  Number pixels: 640K
  Pixels per second: 21.33MB
  User time: 0.020u
  Elapsed time: 0:01.030
  Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Thank you in advance for any suggestions you might have for things to try!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colors change in TIF to PNG conversion

Post by snibgo »

This works fine for me, with IM v6.9.0-0:

Code: Select all

convert image2.tif image_colch.png
I've uploaded the output to http://snibgo.com/imforums/image_colch.png . I suggest you download it and try it out.

You are running a very old IM. If the above works, I suggest you upgrade.
snibgo's IM pages: im.snibgo.com
thobbs
Posts: 3
Joined: 2014-11-29T10:44:53-07:00
Authentication code: 6789

Re: Colors change in TIF to PNG conversion

Post by thobbs »

snibgo,

Thank you for trying that out. Unfortunately, your image appears to have nearly the same (incorrect) colors in the problematic image viewers that I listed. The only difference is that some of the darks are a little darker and more saturated.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Colors change in TIF to PNG conversion

Post by snibgo »

Then I suspect something is wrong with "Firefox (on Ubuntu or OSX), Safari on OSX, or the "Image Viewer" program on Ubuntu".
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: Colors change in TIF to PNG conversion

Post by fmw42 »

If you want to make the viewers more consistent add an explicit profile (such as sRGB.icc) to you resulting image. Many viewers/browser interpret the colors differently if there is no specific profile.
thobbs
Posts: 3
Joined: 2014-11-29T10:44:53-07:00
Authentication code: 6789

Re: Colors change in TIF to PNG conversion

Post by thobbs »

fmw42,

Thanks for the suggestion. I attempted to add a profile to the PNG image like so:

Code: Select all

convert image.png -profile sRGB_v4_ICC_preference.icc image.png
However, this doesn't seem to affect the appearance of the image or add a Profile section to the identify -verbose output. Based on this comment, it seems like sRGB is treated specially for PNG files: viewtopic.php?t=22444#p93443.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Colors change in TIF to PNG conversion

Post by fmw42 »

Adding a profile will show in the profiles section of the IM verbose information if done correctly. It may not affect the appearance on some viewers, but may on others. At least that was my experience a while back.

Code: Select all

convert logo: logo.png
identify -verbose logo.png

Code: Select all

  Properties:
    date:create: 2014-11-29T14:24:58-08:00
    date:modify: 2014-11-29T14:24:58-08: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-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 3
    png:IHDR.color_type: 3 (Indexed)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 640, 480
    png:PLTE.number_colors: 256
    png:sRGB: intent=0 (Perceptual Intent)
    png:text: 2 tEXt/zTXt/iTXt chunks were found
    png:tIME: 2014-11-29T14:24:58Z
    signature: 5c701306a9a985a0c93c8d11a1e761d7f8637577697fc60d7189b221388f8edf
  Artifacts:
    filename: logo.png
    verbose: true
  Tainted: False
  Filesize: 27.4KB
  Number pixels: 307K
  Pixels per second: 307.2GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.0-0 Q16 x86_64 2014-11-18 http://www.imagemagick.org

Code: Select all

convert logo.png -profile /Users/fred/images/profiles/sRGB.icc logo2.png
identify -verbose logo2.png

Code: Select all

 Properties:
    date:create: 2014-11-29T14:25:45-08:00
    date:modify: 2014-11-29T14:25:45-08:00
    icc:copyright: sRGB built-in
    icc:description: sRGB built-in
    icc:manufacturer: (lcms internal)
    icc:model: sRGB built-in
    png:bKGD: chunk was found (see Background color, above)
    png:cHRM: chunk was found (see Chromaticity, above)
    png:iCCP: chunk was found
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 3
    png:IHDR.color_type: 3 (Indexed)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 640, 480
    png:PLTE.number_colors: 256
    png:text: 6 tEXt/zTXt/iTXt chunks were found
    png:tIME: 2014-11-29T14:24:58Z
    signature: 5c701306a9a985a0c93c8d11a1e761d7f8637577697fc60d7189b221388f8edf
  Profiles:
    Profile-icc: 6876 bytes
  Artifacts:
    filename: logo2.png
    verbose: true
  Tainted: False
  Filesize: 30KB
  Number pixels: 307K
  Pixels per second: 307.2GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.0-0 Q16 x86_64 2014-11-18 http://www.imagemagick.org
see

Profiles:
Profile-icc: 6876 bytes

in the latter but not the former.

Be sure you have your exact named profile on your system and provide the full path to it.
Post Reply