Problems specifying transparency for gif

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
tallchris11

Problems specifying transparency for gif

Post by tallchris11 »

Sometimes it’s the simplest things that give you the most trouble….

I’m trying to specify the transparency of a gif image, and it’s not taking. I’m using IM “ImageMagick 6.3.0 11/05/06 Q16”, on windows in cygwin. I’m converting arrowrr.gif to s.gif and I’ve tried things like:

convert arrowrr.gif -transparent black s.gif
convert arrowrr.gif -transparent-color black s.gif
convert arrowrr.gif -background None -transparent-color black s.gif

And more combinations and putting them in different orders and such. However every time I do “identify –verbose s.gif” it says no transparency. The output in below, and is always the same. Thanks for any help.

$ identify -verbose s.gif
Image: s.gif
Format: GIF (CompuServe graphics interchange format)
Class: PseudoClass
Geometry: 7x11
Type: PaletteMatte
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 1-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit
Channel statistics:
Red:
Min: 0 (0)
Max: 255 (1)
Mean: 82.7922 (0.324675)
Standard deviation: 119.405 (0.468253)
Green:
Min: 0 (0)
Max: 189 (0.741176)
Mean: 22.4026 (0.0878533)
Standard deviation: 47.0397 (0.184469)
Blue:
Min: 0 (0)
Max: 180 (0.705882)
Mean: 14.2857 (0.0560224)
Standard deviation: 43.8838 (0.172093)
Alpha:
Min: 255 (1)
Max: 0 (0)
Mean: 82.7922 (0.324675)
Standard deviation: 119.405 (0.468253)
Alpha: none #00000000
Colors: 3
Histogram:
52: none #00000000
20: rgb(255,39,10) #FF270A
5: rgb(255,189,180) #FFBDB4
Colormap: 3
0: black #000000
1: rgb(255,39,10) #FF270A
2: rgb(255,189,180) #FFBDB4
Rendering intent: Undefined
Resolution: 72x72
Units: Undefined
Filesize: 64b
Interlace: None
Background color: none
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: none
Page geometry: 7x11+0+0
Dispose: Undefined
Compression: LZW
Orientation: Undefined
Signature: 931d53aa59a3bf8ed21e1efc95e347532ba8d0e45d79085107138fe8e7b354c9
Tainted: True
Version: ImageMagick 6.3.0 11/05/06 Q16 http://www.imagemagick.org
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problems specifying transparency for gif

Post by Bonzo »

Adding a link to your image would help.

Is the black you are trying to convert to transparent actualy black or is it already transparent and it just the way its being displayed ?

Code: Select all

exec("convert original.jpg -fuzz 10% -transparent black transparent.gif");
The above works for me on my server, the original was a jpg and the only other difference is the -fuzz.
tallchris11

Re: Problems specifying transparency for gif

Post by tallchris11 »

Thanks for your reply. It turns out ImageMagick is working fine. It was the program that was loading images that had an error and wasn't treating the image as transparent. I don't get why PhotoShop shows the image as transparent, but the identify program says it isn't. That's what threw me.
tallchris11

Re: Problems specifying transparency for gif

Post by tallchris11 »

The issue I have is the program I'm using expects the transparent color to be at index 0 in the palette. As far as I can tell, there is no way to get ImageMagick to put the transparent color (in my case magenta) at index 0. Does anyone know a work-around for this?

Thanks -
tallchris11

Re: Problems specifying transparency for gif

Post by tallchris11 »

I have yet to find a way to automate the process of specifing a particular color at palette index 0. It can be done in photoshop by hand, but I can't automate it. Does anyone know a way?

- Thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problems specifying transparency for gif

Post by anthony »

The only way to force the transparent color to be specifically index 0 is to use a lower level program to set it that way. Try giftrans.
http://www.cit.gu.edu.au/~anthony/software/#giftrans
as one posible solution.

Basically it is a very poor program that insists on the transparency to be index 0.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply