Transparency problem with ico conversion

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
smellycamel

Transparency problem with ico conversion

Post by smellycamel »

When I convert certain .ico files (e.g.: http://www.reuters.com/resources/images/favicon.ico) to .gif or .jpg or .png using the Image Magick command line interface, the transparent background is converted to a black background. I've interrogated the .ico files and found the default colour for the transparency is indeed set to black, but I want to set the background to white.

I realise similar issues have been reported before, but I've gone right through the forums, here and elsewhere, and tried every solution recommended to overcome similar variations on this problem (-transparent-color, -background, -matte, -colorize, -fill, -opaque, -flatten, -swap, -compose, -composite) and had no success at all. I've even tried it on both Vista and Linux platforms.

So, can anyone demonstrate how to convert a .ico to gif/jpg/png using the command line interface so the transparency converts to white rather than black?

Many thanks.
strawberryfield

Re: Transparency problem with ico conversion

Post by strawberryfield »

I think this is the same problem I have posted some days ago: any transparency is converted to black matte.

try

convert -size 100x100 xc:none test.png

if this convert to a black square the only solution i found was to reinstall an old 6.2.7
smellycamel

Re: Transparency problem with ico conversion

Post by smellycamel »

Many thanks for the suggestion, strawberryfield, but that just produced another black background for me :( I'll look at your suggestion of installing version 6.2.7 instead (I'm using 6.3.7), but I've found Vista isn't brilliant with earlier versions of Image Magick.

Thanks again, but the challenge still remains - has anyone a solution?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparency problem with ico conversion

Post by anthony »

strawberryfield just pointed out that this was simular to another problem in IM forum.

The solution is the same, set a background color wanted and flatten the image to remove the transparency, and thus defining the color for transparency.

Code: Select all

  convert image.png -background white -flatten -resize 32x32 image.ico
Just using -flatten on its own is no good, as is just using a setting, both must be used together!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
smellycamel

Re: Transparency problem with ico conversion

Post by smellycamel »

Thanks for the replies given on this topic. I believe I've discovered the problem.

The convert command (from .ico to gif/jpg/png), produced a black background for the transparency whether I ran it on Vista or Linux. However, using a mogrify command along these lines:

mogrify -format gif /home/somesite/www/images/icons/*.ico[0]

actually worked fine on Linux, but I'd missed this first time around because the same command (with paths amended for Windows) had produced, and continues to produce, a black background on Vista.

Whether this is an issue with the setup of my own machines or (yet another) problem with Windows Vista, I cannot say, but I hope this helps others, and thanks again for the replies.
Post Reply