possible bug -unique-colors IM 6.9.0.3 Mac OSX Snow Leopard

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 -unique-colors IM 6.9.0.3 Mac OSX Snow Leopard

Post by fmw42 »

I have a PNG image that has only 4 colors and one is a white background. If I add an alpha channel to it, the histogram shows transparent white. If I use -unique colors, it shows transparent black.

Input:
http://www.fmwconcepts.com/misc_tests/u ... esign4.png

Code: Select all

convert design4.png -format "%c" histogram:info:
181054: ( 16, 3, 78) #10034E srgb(16,3,78)
51286: (178, 32, 24) #B22018 srgb(178,32,24)
1277: (178,211,239) #B2D3EF srgb(178,211,239)
565759: (255,255,255) #FFFFFF white

Code: Select all

convert design4.png -unique-colors txt:
0,0: (16,3,78) #10034E srgb(16,3,78)
1,0: (178,32,24) #B22018 srgb(178,32,24)
2,0: (178,211,239) #B2D3EF srgb(178,211,239)
3,0: (255,255,255) #FFFFFF white


Now if I add a binary alpha channel so that the white background is transparent, I get:

Code: Select all

convert design4.png \
\( -clone 0 -fill black +opaque white -negate \) \
-alpha off -compose copy_opacity -composite \
design4a.png
http://www.fmwconcepts.com/misc_tests/u ... sign4a.png

Code: Select all

convert design4a.png -format "%c" histogram:info:
181054: ( 16, 3, 78,255) #10034E srgba(16,3,78,1)
51286: (178, 32, 24,255) #B22018 srgba(178,32,24,1)
1277: (178,211,239,255) #B2D3EF srgba(178,211,239,1)
565759: (255,255,255, 0) #FFFFFF00 srgba(255,255,255,0)

Code: Select all

convert design4a.png -unique-colors txt:
0,0: (16,3,78,1) #10034E srgba(16,3,78,1)
1,0: (178,32,24,1) #B22018 srgba(178,32,24,1)
2,0: (178,211,239,1) #B2D3EF srgba(178,211,239,1)
3,0: (0,0,0,0) #00000000 none
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: possible bug -unique-colors IM 6.7.0.3 Mac OSX Snow Leopard

Post by dlemstra »

[snip]

Forget my previous post, let me see if I can figure out whats wrong.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: possible bug -unique-colors IM 6.9.0.3 Mac OSX Snow Leopard

Post by snibgo »

I think "-unique-colors" regards all fully-transparent pixels as the same colour, and equivalent to transparent black. However, it then doesn't correctly group these together. For example:

f:\web\im>%IM%convert xc:red xc:blue +append -alpha transparent txt:
# ImageMagick pixel enumeration: 2,1,65535,srgba
0,0: (100%,0%,0%,0) #FFFF000000000000 srgba(255,0,0,0)
1,0: (0%,0%,100%,0) #00000000FFFF0000 srgba(0,0,255,0)

f:\web\im>%IM%convert xc:red xc:blue +append -alpha transparent -unique-colors txt:
# ImageMagick pixel enumeration: 2,1,65535,srgba
0,0: (0%,0%,0%,0) #0000000000000000 none
1,0: (0%,0%,0%,0) #0000000000000000 none


I would expect the second result to have one pixel, not two.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -unique-colors IM 6.9.0.3 Mac OSX Snow Leopard

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-4 Beta, available by sometime tomorrow. Thanks.
Post Reply