php - PNG file is NOT keeping transparency? -
i'll using these variables throughout:
$rootdir = $_server["document_root"]; $rootfile = "http://www.scottandjessiecooper.com/webtutorials/images/smiley.png"; $newfile = "$rootdir/images/tmp/new_smiley.png"; when use function, have no problems transparency
function save_image($root, $saveto){ copy($root, $saveto); } save_image( $rootfile, $newfile ); // root can file or url however need use image_resource cam manipulate rootfile if needed
so treid this:
if ( file_exists( $newfile ) ) unlink ($newfile); $image = imagecreatefrompng( $rootfile ); imagepng( $image, $newfile ); imagedestroy( $image ); now when use this:
<img src="<?=$newfile?>" /> i lose transparency. background goes black!
so tried outputting image make sure wasn't saving caused problem:
if ( file_exists( $newfile ) ) unlink ($newfile); $image = imagecreatefrompng( $rootfile ); header('content-type: image/png'); imagepng( $image ); imagedestroy( $image ); still no avail...
help?
you need enabled alpha blending , save alpha. found after 10 sec google search: http://www.php.net/manual/en/function.imagecreatefrompng.php#43024
Comments
Post a Comment