possible bug .mpc format IM 6.7.3.1 Q16

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 bug .mpc format IM 6.7.3.1 Q16

Post by fmw42 »

Version: ImageMagick 6.7.3-1 2011-10-13 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features:

Mac OSX Tiger:

The following should make an image that is transparent wherever not white and gray(1) where the image was white.

The following works:

convert logo: logo.mpc
color="white"
convert -background none \
\( logo.mpc +transparent "$color" -fill "gray(1,1)" -opaque "$color" \) \
-flatten test.mpc
display test.mpc

Histogram:
50956: ( 0, 0, 0, 0) #00000000 none
256244: ( 1, 1, 1,255) #010101 rgba(1,1,1,1)



But the following fails and I get a black and white image:

convert logo: logo.mpc
convert logo.mpc -matte -channel A -evaluate set 0 logo_trans.mpc
color="white"
convert logo_trans.mpc \
\( logo.mpc +transparent "$color" -fill "gray(1,1)" -opaque "$color" \) \
-flatten test.mpc
display test.mpc

Histogram:
256244: ( 1, 1, 1,255) #010101 rgba(1,1,1,1)
50956: (255,255,255,255) #FFFFFF white


Is this a bug or am I misunderstanding something here?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug .mpc format IM 6.7.3.1 Q16

Post by fmw42 »

Further investigation seems to find that it appears to be a -flatten issue vs -composite

This does not work:

convert logo: logo.mpc
convert logo.miff -matte -channel A -evaluate set 0 logo_trans.mpc
color="white"
convert logo_trans.mpc \
\( logo.mpc +transparent "$color" -fill "gray(1,1)" -opaque "$color" \) \
-flatten test.mpc
display test.mpc


Nor does this:

convert logo: logo.mpc
convert logo.miff -matte -channel A -evaluate set 0 logo_trans.mpc
color="white"
convert logo_trans.mpc \
\( logo.mpc +transparent "$color" -fill "gray(1,1)" -opaque "$color" \) \
-compose over -flatten test.mpc
display test.mpc


But this works:

convert logo: logo.mpc
convert logo.miff -matte -channel A -evaluate set 0 logo_trans.mpc
color="white"
convert logo_trans.mpc \
\( logo.mpc +transparent "$color" -fill "gray(1,1)" -opaque "$color" \) \
-compose over -composite test.mpc
display test.mpc
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug .mpc format IM 6.7.3.1 Q16

Post by magick »

Flatten composites the images onto a canvas of background color. Add -background none just before -flatten.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug .mpc format IM 6.7.3.1 Q16

Post by fmw42 »

Thanks. My mistake. :oops: I thought one could use a transparent background image. Sorry for the false alarm.
Post Reply