Jump to content

imagecreatefrompng looses transparency.


lynxus

Recommended Posts

Hi Guys,

 

I have a script that will display an image based on what the user selected in a DB.

 

so for instance.

 

a user will have <img src="http://blaa.com/image.php?siteid=1234">

 

Now my

image.php will

 

<?
// do lost of other error checking etc
// add their ip and time to a DB for visitor tracking.

// now show the user a image

$style = $_GET['siteid'];

   $image = imagecreatefrompng('http://status.imsupporting.com/'.$style.'off.png');

}
}

// and now... we display the image
imagepng($image);
imagedestroy($image);

?>

this doesn't preserve the transparency , Is there a better way to do all this?

 

-G

 

 

Link to comment
Share on other sites

Good stuff thanks :)

 

all i did was add

 

imagealphablending($image, true); // setting alpha blending on

imagesavealpha($image, true); // save alphablending setting (important)

 

just above

imagepng($image);

imagedestroy($image);

 

 

Thanks

G

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.