Page 1 of 1

How to create Windows icon with boolean transparency

Posted: 2012-07-06T03:57:33-07:00
by eyebex
Hi,

I'm using version 6.7.7-2 2012-06-15 Q16 on a Mac and am struggling to rasterize this vectors graphic to a 256x256 icon file with a color palette of 255 colors and 1 color reserved for boolean transparency. So far I'm using

Code: Select all

convert -colorspace sRGB -density 256x256 Git-Icon-1788C.eps -resize 256x256 -quantize transparent -colors 255 -transparent-color \#00000000 git.ico
but that results in a black background and rough edges of the logo. Also, some program (like Safari) only display the icon in black / white, so I suspect "-color 255" reduces the image to 2 instead of 255 colors (as there are only 2 distinct color in the image), and although there seems to be a palette, Safari cannot handle it.

I would not mind to get it working by converting to a GIF first (as IM seems to do the boolean transparency magic correctly in that case), however when doing

Code: Select all

convert -colorspace sRGB -density 256x256 Git-Icon-1788C.eps -resize 256x256 git.gif
convert git.gif git.ico
the GIF image looks fine, but the ICO file again has a black background (although the rough edges of the logo are gone).

Any hints how to get this right?

Note: I've edited my post to more correctly describe the behavior I'm seeing.

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-06T09:42:33-07:00
by fmw42
I am not an expert on ico, but try

convert -colorspace sRGB -density 256x256 Git-Icon-1788C.eps -resize 256x256 git.gif
convert git.gif -type palettematte git.ico

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-07T02:51:51-07:00
by whugemann
At http://www.imagemagick.org/script/formats.php the ICON format is marked as read-only, thus I think that the writing support is very limited. I have tried to write icons with indexed colours with ImageMagick on my Windows computer, but failed too.

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-09T00:44:14-07:00
by eyebex
whugemann wrote:At http://www.imagemagick.org/script/formats.php the ICON format is marked as read-only, thus I think that the writing support is very limited. I have tried to write icons with indexed colours with ImageMagick on my Windows computer, but failed too.
That's interesting because there's actually a tutorial on how to create favicons with IM.

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-09T01:00:14-07:00
by eyebex
fmw42 wrote:convert -colorspace sRGB -density 256x256 Git-Icon-1788C.eps -resize 256x256 git.gif
convert git.gif -type palettematte git.ico
Thanks, that works, but I realized it in fact already worked before without "-type palettematte". It was my image viewer that was buggy and is not able to display boolean transparency for 1-bit icons correctly. Neither is Safari on Mac, is does not get the palette colors for 1-bit icons right and always assumes them to be black / white.

So, my remaining problem seems to be that a few programs cannot handle correctly the 1-bit color with indexed / boolean transparency ICO images that IM writes, and I'm searching for a way to force color depth to 8-bit. Will experiment with "-depth" and report back here later.

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-09T01:09:42-07:00
by eyebex
eyebex wrote:Will experiment with "-depth" and report back here later.
It seems "-depth 8" has not effect when writing ICO files, they still are 32-bit :-(

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-09T01:48:34-07:00
by whugemann
It seems "-depth 8" has not effect when writing ICO files, they still are 32-bit.
Well, that's what I said: I tried to write icons with indexed colours, but without success; -depth has no influence, neither has -colors 256. I have just tested the favicon example you mentioned, using rose: as the test image. It works, but also generates a full colour icon.

Re: How to create Windows icon with boolean transparency

Posted: 2012-07-09T02:16:15-07:00
by eyebex
Thanks for double-checking. I'm currently looking into using NConvert instead, and first tests seem to be promising.