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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.