image - PHP generated png background issue -
my php knowledge limited... searched, found , edited script write text on png, transparency not present:
<?php $string = "username"; $string2 = "example.com"; $image = imagecreatefrompng("http://i.imgur.com/y6hwkkw.png"); $cor = imagecolorallocate($image, 0, 0, 0); imagestring($image,5,126,22,urldecode($string),$cor); header('content-type: image/png'); imagepng($image,null); $stype = "png"; if ($stype = "png") { // integer representation of color black (rgb: 0,0,0) $background = imagecolorallocate($image, 0, 0, 0); // removing black placeholder imagecolortransparent($image, $background); // turning off alpha blending (to ensure alpha channel info // preserved, rather removed (blending rest of // image in form of black)) imagealphablending($image, false); // turning on alpha channel info saving (to ensure total range // of transparency preserved) imagesavealpha($image, true); } ?>
live script here faulty result ideal image
i have been searching web , couldn't find solution if can, please take time help me out
thank much
you need 'enable' transparency.
$string = "username"; $string2 = "example.com"; $image = imagecreatefrompng("http://i.imgur.com/y6hwkkw.png"); $cor = imagecolorallocate($image, 0, 0, 0); $background = imagecolorallocate($image, 0, 0, 0); imagecolortransparent($image, $background); imagealphablending($image, false); imagesavealpha($image, true); imagestring($image,5,126,22,urldecode($string),$cor); header('content-type: image/png'); imagepng($image,null);
php image printing png generator
No comments:
Post a Comment