possible MPC format bug IM 6.8.3.6

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible MPC format bug IM 6.8.3.6

Post by fmw42 »

Mac OSX Snow Leopard


convert -version
Version: ImageMagick 6.8.3-6 2013-02-27 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib fftw fontconfig freetype gslib jng jp2 jpeg lcms lqr lzma openexr png ps tiff x xml zlib


The following two sets of commands produce quite different results and I believe the issue is with MPC.

The MIFF results match those using PNG. You will note that the first two lines produce the same sets of unique colors and the images look the same for the first line. So it would appear to be something in the last line.

# good
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -write show: 1tmp1.miff
convert 1tmp1.miff -unique-colors txt:- | tail -n +2 | tr -cs ".0-9\n" " " | cut -d' ' -f3
convert 1tmp1.miff -channel rgba -fill white -opaque "gray(170)" -fill none +opaque white show:

# bad
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -write show: 1tmp1.mpc
convert 1tmp1.mpc -unique-colors txt:- | tail -n +2 | tr -cs ".0-9\n" " " | cut -d' ' -f3
convert 1tmp1.mpc -channel rgba -fill white -opaque "gray(170)" -fill none +opaque white show:
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible MPC format bug IM 6.8.3.6

Post by magick »

Both PNG and MIFF force a depth of 8 whereas the MPC format does not, it stays at 16 bits for ImageMagick Q16:

Code: Select all

convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.miff
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.png
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.mpc
compare -metric rmse 1tmp1.png 1tmp1.miff null:
0 (0)
compare -metric rmse 1tmp1.mpc 1tmp1.miff null:
99.6065 (0.0015199)
Add -depth 8 to your command line to get identical results:

Code: Select all

convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.miff
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.png
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.mpc
compare -metric rmse 1tmp1.png 1tmp1.miff null:
0 (0)
compare -metric rmse 1tmp1.mpc 1tmp1.miff null:
0 (0)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible MPC format bug IM 6.8.3.6

Post by fmw42 »

Thanks. That fixed it in my actual script as well.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible MPC format bug IM 6.8.3.6

Post by anthony »

And this I have an objection to..


-depth here does not just set the output image depth (as a setting), but actually modifies the in memory image (reducing the pixel quality).

This means exactly where -depth occurs can have a big impact on image results, as it is actually an operator.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply