views:

17

answers:

1

I'm using gd in PHP to add some text to a gif image from Illustrator. I've added text and drawn figures, and no matter how I specify the color, they all show up as gray (I'm guessing 50% gray).

I opened the image in MS Paint and re-saved it as a gif. When I did that, it gave a warning of color loss. However, the colors show up correctly when I add things using gd on the new image.

What's the deal? Does it have something to do with the palette Illustrator uses when saving the original?

I'm using PHP Version 5.2.6-1+lenny9. Here's the gd info:

GD Support  enabled 
GD Version  2.0 or higher 
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.3.7 
T1Lib Support   enabled 
GIF Read Support    enabled 
GIF Create Support  enabled 
JPG Support     enabled 
PNG Support     enabled 
WBMP Support    enabled
+1  A: 

GIF is an indexed colour format - this means that the image has a limited palette of colours to choose from (up to 256, if I recall correctly, with GIF). When you process the image with GD, you have to make sure you're correctly choosing the kind of image resource to copy things, alter or whatever. If you do imagecreatetruecolor(...) for example, then this might be the problem - as the image resource is using 24(?) bit true colour, then having an indexed colour resource copied into it.. something like this.

Without doing any deeper research (never had this particular issue), I'd guess using transparent PNG instead of GIF would be a good fix.

e: also, when saving out from photoshop or illustrator, always use "Save for web" to avoid some other weird colour issues across browsers.

danp
Well, this is for a email mailing, so I think we need to use GIF for email client support. Not sure that PNG is well-supported.
It's absolutely fine to use PNGs in emails.
danp