Juan Nin wrote:
> I'm adding text to images using the native gd in PHP 4.3.9
>
> I have no problems with jpg images, but with gif ones, the colour of
> the text added to the image always results a dark grey
> The image itself and text are fine, but not the colour, which should be
> white..
>
> Has anyone experienced this problem?
>
> Used functions are:
>
>
>       imagecreatefromgif
>       imagettftext
>       imagegif

When you create that image from the original GIF, you are inheriting the
COLOR PALLETTE that is in that GIF.

The original GIF maker may well have restricted you to, say, 4 colors, in
order to make the GIF really small, none of which colors are white.

I'm assuming you are using http://php.net/imagecolorallocate already, and
are trying to use  255, 255, 255 to get white.

However, if the pallette is only allowed to have 4 colors, and they are
already in use, you ain't gonna get your white color -- Your
imagecolorallocate will return -1 -- Which shouldn't work too good at all
in the rest of your script...

So I'm a bit confused exactly how you got the gray color.

That said, here are some possible ideas.

#1.
Check all your return codes from all your functions.  If you *think* you
are getting a color, but you get -1, something went wrong.  Catch it, deal
with it, and do something smart about it.

#2.
Use http://php.net/imagecreatetruecolor to make your image.
Then use http://php.net/imagecreatefromgif to pull in the GIF
Then use http://php.net/imagecopy to *copy* the GIF into your image.

#3.
There are PHP functions to examine the pallette.  Use them.  Figure out
where the gray is coming from and why.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to