Behavior changes in IM releases: how to get early heads up?

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
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Behavior changes in IM releases: how to get early heads up?

Post by pipitas »

I have 2 versions of 'convert' on this system (Mac OS X Lion):

Code: Select all

/opt/local/bin/convert -version
  Version: ImageMagick 6.7.9-0 2012-08-17 Q16 http://www.imagemagick.org
  Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
  Features:  OpenCL HDRI  

/usr/local/bin/convert -version
  Version: ImageMagick 6.7.6-9 2012-05-12 Q16 http://www.imagemagick.org
  Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
  Features:  

The first one is my 'regular' one (and the newest available), installed via MacPorts (and it's dynamically linked)

The second one is from ... I can't remember (it's definitely not built locally), but it's statically linked.

Anyways, I've been running these two commands, and discovered that they produced quite a different type of output, which is very strikingly visible:

Code: Select all

/usr/local/bin/convert screenshot.jpeg -type grayscale grayscale-6.7.6-9.png 
/opt/local/bin/convert screenshot.jpeg -type grayscale grayscale-6.7.9-0.png


So I look for the differences:

Code: Select all

identify -verbose grayscale-6.7.6-9.png > grayscale-6.7.6-9.txt 
identify -verbose grayscale-6.7.9-0.png > grayscale-6.7.9-0.txt 
sdiff -sbB -w 150 grayscale-6.7.6-9.txt grayscale-6.7.9-0.txt > diff.txt
cat diff.txt

Image: grayscale-6.7.6-9.png                                              |     Image: grayscale-6.7.9-0.png
  Resolution: 28.34x28.34                                                 |       Resolution: 72x72
  Print size: 12.35x14.2555                                               |       Print size: 4.86111x5.61111
  Units: PixelsPerCentimeter                                              |       Units: PixelsPerInch
  Type: Palette                                                           |       Type: Grayscale
                                                                          >       Base type: Grayscale
  Colorspace: sRGB                                                        |       Colorspace: RGB
    red: 8-bit                                                            |         gray: 8-bit
    green: 8-bit                                                          <
    blue: 8-bit                                                           <
    Red:                                                                  |         Gray:
      mean: 200.265 (0.785352)                                            |           mean: 164.009 (0.643174)
      standard deviation: 57.0152 (0.223589)                              |           standard deviation: 66.6053 (0.261197)
      kurtosis: 2.87636                                                   |           kurtosis: 0.57041
      skewness: -1.92907                                                  |           skewness: -1.08054
    Green:                                                                <
      min: 0 (0)                                                          <
      max: 255 (1)                                                        <
      mean: 200.265 (0.785352)                                            <
      standard deviation: 57.0152 (0.223589)                              <
      kurtosis: 2.87636                                                   <
      skewness: -1.92907                                                  <
    Blue:                                                                 <
      min: 0 (0)                                                          <
      max: 255 (1)                                                        <
      mean: 200.265 (0.785352)                                            <
      standard deviation: 57.0152 (0.223589)                              <
      kurtosis: 2.87636                                                   <
      skewness: -1.92907                                                  <
  Image statistics:                                                       <
    Overall:                                                              <
      min: 0 (0)                                                          <
      max: 255 (1)                                                        <
      mean: 200.265 (0.785352)                                            <
      standard deviation: 57.0152 (0.223589)                              <
      kurtosis: 2.87636                                                   <
      skewness: -1.92907                                                  <
       597: (  0,  0,  0) #000000 black                                   |            810: (  0,  0,  0) #000000 rgb(0,0,0)
        90: (  1,  1,  1) #010101 srgb(1,1,1)                             |             62: (  1,  1,  1) #010101 rgb(1,1,1)
  [..............]
  [...skipping...]
  [..............]
       254: (254,254,254) #FEFEFE srgb(254,254,254)                       |            254: (254,254,254) #FEFEFE rgb(254,254,254)
       255: (255,255,255) #FFFFFF white                                   |            255: (255,255,255) #FFFFFF rgb(255,255,255)
  Rendering intent: Perceptual                                            |       Rendering intent: Undefined
  Gamma: 0.45455                                                          |       Gamma: 1
  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)                                           <
  Background color: white                                                 |       Background color: rgb(255,255,255)
  Border color: srgb(223,223,223)                                         |       Border color: rgb(223,223,223)
  Matte color: grey74                                                     |       Matte color: rgb(189,189,189)
  Transparent color: black                                                |       Transparent color: rgb(0,0,0)
  Orientation: Undefined                                                  |       Orientation: TopLeft
    date:create: 2012-08-18T04:24:48+02:00                                |         date:create: 2012-08-18T04:24:51+02:00
    date:modify: 2012-08-18T04:24:48+02:00                                |         date:modify: 2012-08-18T04:24:51+02:00
                                                                          >         exif:ExifImageLength: 404
                                                                          >         exif:ExifImageWidth: 350
                                                                          >         exif:ExifOffset: 90
                                                                          >         exif:Orientation: 1
                                                                          >         exif:ResolutionUnit: 2
                                                                          >         exif:XResolution: 72/1
                                                                          >         exif:YResolution: 72/1
    png:cHRM                 : chunk was found (see Chromaticity, abov    |         png:gAMA                 : gamma=1 (See Gamma, above)
    png:gAMA                 : gamma=0.45454544 (See Gamma, above)        <
    png:sRGB                 : intent=0 (Perceptual Intent)               |         png:text                 : 5 tEXt/zTXt/iTXt chunks were found
    png:text                 : 4 tEXt/zTXt/iTXt chunks were found         |         png:text-encoded profiles: 1 were found
    signature: e76c50c69201379387a2e7a3e8e36a49aede3b5f38f2fe20763f7d7    |         signature: 30fa3d6441cf466e3a6edd76f5d746b80852efb2900bbe6fa271f8a
                                                                          >       Profiles:
                                                                          >         Profile-exif: 126 bytes
    filename: grayscale-6.7.6-9.png                                       |         filename: grayscale-6.7.9-0.png
  Filesize: 27.1KB                                                        |       Filesize: 29.3KB
  Pixels per second: 14.14MB                                              |       Pixels per second: 0B
  Elapsed time: 0:01.009                                                  |       Elapsed time: 0:01.000
So my questions in this context are:
  • Are these changes for the 'simple' grayscaling operation between my 2 IM versions intentional and a well-known fact?
  • What can I do in the future to get early notification if something that fundamental changes? Is there a comprehensive ChangeLog available somewhere? (On the one hand I'd like to run the newest and officially recommended version with the latest improvements and bugfixes -- on the other hand I'd like my scripts to keep working...)
  • Also note, how the newer version 6.7.9-0 doesn't indicate a valid value for 'Pixels per second' while the older one did.
----

UPDATE:

The reason why this did bite me is this commandline:

Code: Select all

convert screenshot.jpeg                       \
    -scale 1000%                              \
    -blur 1x65535 -blur 1x65535 -blur 1x65535 \
    -contrast                                 \
    -normalize                                \
    -despeckle -despeckle                     \
    -type grayscale                           \
    -sharpen 1                                \
    -posterize 3                              \
    -negate                                   \
    -gamma 100                                \
    -scale 10%                                \
     b+w.png
The purpose of this command was to prepare a screenshot image for OCR with Tesseract. The two said IM versions produced this difference (which I narrowed down to the not-so-dramatically-looking '-type grayscale' command part):
Image
The original screenshot was from an iPad:
Image
Last edited by pipitas on 2012-08-17T20:44:26-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Behavior changes in IM releases: how to get early heads

Post by fmw42 »

grayscale images became linear rather than non-linear (sRGB) at about IM 6.7.8.3, thus the difference. see viewtopic.php?f=4&t=21269

It can be fixed to make it the same as it was, but I need to see your input image to be sure.

try

convert screenshot.jpeg -set colorspace RGB -type grayscale grayscale-6.7.9-0.png
or
convert screenshot.jpeg -type grayscale -colorspace sRGB grayscale-6.7.9-0.png

There is a changelog at http://www.imagemagick.org/script/changelog.php
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Behavior changes in IM releases: how to get early heads

Post by pipitas »

fmw42 wrote:grayscale images became linear rather than non-linear (sRGB) at about IM 6.7.8.3, thus the difference. see viewtopic.php?f=4&t=21269

It can be fixed to make it the same as it was, but I need to see your input image to be sure.

try

convert screenshot.jpeg -set colorspace RGB -type grayscale grayscale-6.7.9-0.png
or
convert screenshot.jpeg -type grayscale -colorspace sRGB grayscale-6.7.9-0.png
Thanks a lot, fmw42. Yes, this restores the same behavior as before... almost, veeeerrry close:

Code: Select all

compare grayscale-6.7.6-9.png grayscale-6.7.9-0---oldbehavior.png -compose src d.png
Image
fmw42 wrote:There is a changelog at http://www.imagemagick.org/script/changelog.php
Again: thanks for this info (I should have found it on my own). However, it's a pity that this doesn't seem to give loud, timely warning, unless one follows every single item in it... But it's better than nothing for sure ;-)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Behavior changes in IM releases: how to get early heads

Post by fmw42 »

This works for me


convert screenshot.jpg \
-scale 1000% \
-blur 1x65535 -blur 1x65535 -blur 1x65535 \
-contrast \
-normalize \
-despeckle -despeckle \
-sharpen 1 \
-posterize 3 \
-negate \
-gamma 100 \
-scale 10% \
-type grayscale \
screenshot_proc.png


Note I simply moved -type grayscale to the end where I think it properly belongs.
Post Reply