PDA

View Full Version : php images and transparency



kosi
01-09-2007, 06:36 AM
I am so confused by php images when it comes to transparency . . .

I tried to put a border around a jpg by merging it with a png that had a transparent center, but every time I merge the images, the center of the png comes out matted black. The same thing happens when I use a gif.

I tried to use the imagecolortransparent() function, but it keeps giving me an error. The documentation for this function on php.net is very confusing to me and every other documentation I've seen has simply been a mimic of php.net.

Does anybody know how to use this function? Or at least, to get around using it?

I'm working on php4.4.3, btw.

BLiZZaRD
01-09-2007, 09:00 AM
From what I understand about the function is that only one color can be transparent.

So say you choose black, when you add that image to the function anything in that image that is black will then become transparent.

If you want the background to be transparent you have to call 2 colors, the first acting as a dummy color, to which the function will then use the second color as the transparency color (your background)

Why can't you just take the single image and use photoshop or similar to make your transparency/opacity the way you want and just use that?

djr33
01-09-2007, 11:36 AM
I'm playing with the GD library myself, at the moment.

However, I haven't tried that function, no.

Graphics work from text commands is a pain. I'm tired... been working with it too long tonight.

If I were you, I'd be looking for another more logical solution, not to say that won't work, just that something else might make more sense. I may take a look when my brain isn't already burned out.

However, what Blizzard said sounds promising, so do try that.

kosi
01-09-2007, 09:35 PM
It seems logical that one should allocate a color and then set it to transparent and that that should work, but for some reason it doesn't. For some reason, regardless of what color I allocate, the transparency comes out as the matte color, and when use an image with no matte, the transperancy comes out black.

I would just edit all my images in photoshop, but then i'd need to have two images for each image: one with a border and one without it, and this could become a hassle in the future when i'm adding new images.

Has anybody used this function successfully?