684425 Posted December 27, 2014 Share Posted December 27, 2014 session_start(); $text = rand(10000,99999); $_SESSION["vercode"] = $text; $height = 25; $width = 65; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 255, 255, 255); $white = imagecolorallocate($image_p, 0, 0, 0); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); The code above creates an image with white background. How to change it to create transparent background? Link to comment https://forums.phpfreaks.com/topic/293417-i-want-to-make-transparent-background-here/ Share on other sites More sharing options...
Frank_b Posted December 27, 2014 Share Posted December 27, 2014 http://php.net/manual/en/function.imagecolortransparent.php Link to comment https://forums.phpfreaks.com/topic/293417-i-want-to-make-transparent-background-here/#findComment-1500865 Share on other sites More sharing options...
QuickOldCar Posted December 28, 2014 Share Posted December 28, 2014 I recommend using imagepng To retain transparency throughout multiple layers you need to use imagealphablending and imagesavealpha And be sure to use imagedestroy to free the memory of images created Link to comment https://forums.phpfreaks.com/topic/293417-i-want-to-make-transparent-background-here/#findComment-1500922 Share on other sites More sharing options...
CroNiX Posted December 29, 2014 Share Posted December 29, 2014 jpeg's don't do transparency. Use PNG as mentioned above. Link to comment https://forums.phpfreaks.com/topic/293417-i-want-to-make-transparent-background-here/#findComment-1501060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.