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? Quote 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 Quote 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 Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.