[RESOLVED]possible bug MPC with -fill -opaque IM 6.8.7.9 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

[RESOLVED]possible bug MPC with -fill -opaque IM 6.8.7.9 Q16

Post by fmw42 »

I am trying to reduce colors in an image and then select one color and convert the image for that color to white on black. It works fine with PNG, MIFF, but not MPC (unless I add a non-zero fuzz value).

Works:
convert logo: -depth 8 +dither -colors 24 1tmp1.png
colorArr=(`convert 1tmp1.png -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.png \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:

Works:
convert logo: -depth 8 +dither -colors 24 1tmp1.miff
colorArr=(`convert 1tmp1.miff -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.miff \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:



Does not Work -- result is all black:
convert logo: -depth 8 +dither -colors 24 1tmp1.mpc
colorArr=(`convert 1tmp1.mpc -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.mpc \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:

Works, but only with -fuzz not zero:
convert logo: -depth 8 +dither -colors 24 1tmp1.mpc
colorArr=(`convert 1tmp1.mpc -unique-colors txt: | sed 's/ */ /g' | tail -n +2 | cut -d\ -f3`)
numcolors="${#colorArr[*]}"
echo "${colorArr[*]}"
echo "numcolors=$numcolors"
echo "${colorArr[10]}"
convert 1tmp1.mpc -fuzz 1% \
-fill black +opaque "${colorArr[10]}" -fill white -opaque "${colorArr[10]}" \
show:
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug MPC with -fill -opaque IM 6.8.7.9 Q16 Mac O

Post by magick »

Use
  • convert logo: +dither -colors 24 -depth 8 1tmp1.mpc
Setting -depth 8 right after logo: reduces the image depth to 8, however color reduction uses 16-bits of precision. The MIFF and PNG formats respect the 8-bit depth setting, but MPC does not. It serializes the pixel data directly from memory at 16-bits of precision to disk and when read, 16-bits of precision is read back in. The result is a slightly different set of pixels than when read from a PNG or MIFF image due to differences in precision (PNG / MIFF @ 8-bits, MPC @ 16-bits). Moving the -depth to the end of the command line ensures the pixel data is 8 bits for each of the PNG, MIFF, and MPC image formats.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug MPC with -fill -opaque IM 6.8.7.9 Q16 Mac O

Post by fmw42 »

thanks
Post Reply