Jump to content

make image background transparent for MSIE6


asmith

Recommended Posts

Hi,

 

I use something like this to generate a transparent image which works in FF :

 

header("Content-Type: image/png");

// create the image resource
$image = imagecreatetruecolor(300, 70);
imagesavealpha($image, true);

$trans_colour = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $trans_colour);

 

then I draw what I want in there, with colors and imagettftext() mostly.

at the end :

 

imagepng($image);
imagedestroy($image);

 

all works fine in FF.

but IE6 shows a gray background instead.

 

how can I tune it for IE6?

Is it a way a make the background transparent with GIF image? I guess IE won't miss gif transparents.

Wouldn't using a IE6 png fix, fix the problem here? I forget which one I use as I'm at work, but just google "easy ie6 png fix" and try a few. I really don't recall which one i use when I google it but the one I've found to be the best is when you include a javascript file at the bottom of the page.

 

Good luck!

<?php
// Create a 55x30 image
$im = imagecreatetruecolor(55, 30);
$red = imagecolorallocate($im, 255, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);

// Make the background transparent
imagecolortransparent($im, $black);

// Draw a red rectangle
imagefilledrectangle($im, 4, 4, 50, 25, $red);

// Save the image
imagepng($im, './imagecolortransparent.png');
imagedestroy($im);
?>

 

url.

http://uk.php.net/manual/en/function.imagecolortransparent.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.