News:

Wondering if this will always be free?  See why free is better.

Main Menu

Graphic that blends with any background

Started by Kader, February 25, 2008, 03:06:45 PM

Previous topic - Next topic

Kader

Hi all

I have a couple of questions:
1) Does gd 2 support SVG graphics?
2) A snippet of php code that will allow me to generate a transparent graphic that will blend with any background behind it. Something similar to:


header("Content-type: image/png");
....
....
$height = 20;
$width= 100;
$image = ImageCreate($width, $height);
$background = ImageColorAllocate($image,236,237,243);
$black = ImageColorAllocate($image,0,0,0);
$font = 'arial.ttf';
ImageTTFText($image, 12, 0, 0, 15, $black, $font, $string);
ImagePNG($image);
ImageDestroy($image);


But allows a transparent background


Thanx for the support

Sarge

As far as I know, GD2 doesn't support generation of SVG images, unless you manage to find and install a GD2 plugin for SVG.

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting


Kader

#3
Very easy actually. I have resolved this by using the function:
$background = ImageColorAllocateAlpha($image,255,255,255,127);

Have a look at the code below in an earlier post to get the full picture.

instead of $background = ImageColorAllocate($image,255,255,256);

The last argument 127 means 100% transparency. It's the max value that it can take.

Hope that will be of some use to some of you.

Kader
Suggesting you have great day and even better tomorrow
 

Advertisement: