Transparent background sometimes appears black

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
gottasolveit

Transparent background sometimes appears black

Post by gottasolveit »

I'm using ImageMagick to convert .ico files into transparent .gif files. I'll download a favicon, http://twitter.com/favicon.ico, for example, and convert it to a .gif using the following:

Code: Select all

convert -resize 32x32! -sharpen 10 favicon.ico[0] favicon.gif
In Windows, this works just great. On Linux, sometimes the icons have a black background instead of transparent.

After converting this -- the resulting .gif is this:
http://www.quantcast.com/favicon.ico -- transparent background in both Windows and Linux
http://twitter.com/favicon.ico -- transparent background in Windows, black background in Linux

Anybody know the cure?

Thanks!
gottasolveit

Re: Transparent background sometimes appears black

Post by gottasolveit »

Nobody can offer any insight? This seems like an easy enough problem
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparent background sometimes appears black

Post by fmw42 »

I know nothing about ico files, but both your examples show transparent backgrounds on my Mac OSX using Safari for the browser.

Also see the information about IM 6 syntax at http://www.imagemagick.org/Usage/basics/#cmdline

what IM version are you using

convert -list configure

should show you the full version as 6.4.9-6 for the latest. Perhaps you just have a too old version of IM.

Perhaps you should post a copy of your original file so it can be checked to see if corrupt or some oddity.
gottasolveit

Re: Transparent background sometimes appears black

Post by gottasolveit »

fmw42 wrote:I know nothing about ico files, but both your examples show transparent backgrounds on my Mac OSX using Safari for the browser.
Icons display properly in the browser as being transparent. The problem is when I convert them to a .gif using ImageMagick.

I'm on Ubuntu and have compiled ImageMagick from source. (The default package was somewhat outdated). So, now I'm at version 6.4.9-8.. and I still have this problem.

I'm using this command:

convert -resize 32x32! -sharpen 10 favicon.ico[0] favicon.gif

To test this, download this .ico file: http://twitter.com/favicon.ico
..and try to convert it using the command above. I end up with a black backgrounded .gif instead of transparent one. Does this happen for you?

How do I fix this? Am I using "convert" improperly?


Again, just to clarify, .ico files have transparency. When I use ImageMagick to convert a .ico to a .gif, sometimes the .gif ends up having a black background instead of transparent. This happens about half the time when I use ImageMagick on Linux to convert, but *not* when I use Windows ImageMagick to convert.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Transparent background sometimes appears black

Post by fmw42 »

gottasolveit wrote:
fmw42 wrote:I know nothing about ico files, but both your examples show transparent backgrounds on my Mac OSX using Safari for the browser.
Icons display properly in the browser as being transparent. The problem is when I convert them to a .gif using ImageMagick.

I'm on Ubuntu and have compiled ImageMagick from source. (The default package was somewhat outdated). So, now I'm at version 6.4.9-8.. and I still have this problem.

I'm using this command:

convert -resize 32x32! -sharpen 10 favicon.ico[0] favicon.gif

To test this, download this .ico file: http://twitter.com/favicon.ico
..and try to convert it using the command above. I end up with a black backgrounded .gif instead of transparent one. Does this happen for you?

How do I fix this? Am I using "convert" improperly?


Again, just to clarify, .ico files have transparency. When I use ImageMagick to convert a .ico to a .gif, sometimes the .gif ends up having a black background instead of transparent. This happens about half the time when I use ImageMagick on Linux to convert, but *not* when I use Windows ImageMagick to convert.

All of these commands work fine for me an leave the background transparent:

convert favicon.ico favicon.gif
convert favicon.ico -resize 32x32! -sharpen 10 favicon2.gif
convert favicon.ico[0] -resize 32x32! -sharpen 10 favicon3.gif
convert -resize 32x32! -sharpen 10 favicon.ico[0] favicon4.gif

I am on IM 6.4.9-8 Q16 Mac OSX Tiger

No black background.

What viewer are you using to look at your images? Perhaps IE?
Post Reply