hyster Posted October 1, 2015 Share Posted October 1, 2015 this code works fine apart from it displays the image in the browser, what id like to happen is to have the image save to a folder, I don't understand all the code so I don't no what im looking for <?php $name = 'Hyster'; $img=imagecreatetruecolor(180,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$name); header('Content-Type: image/png'); imagealphablending($img,false); imagesavealpha($img,true); imagepng($img); exit; ?> Quote Link to comment Share on other sites More sharing options...
scootstah Posted October 1, 2015 Share Posted October 1, 2015 As per the manual, the second argument for imagepng() is a filename to save the image. Quote Link to comment Share on other sites More sharing options...
hyster Posted October 1, 2015 Author Share Posted October 1, 2015 thanks scootstah Quote Link to comment Share on other sites More sharing options...
hyster Posted October 1, 2015 Author Share Posted October 1, 2015 just come across another issue lol. I cant use any html when using the code, I want to redirect after the code runs. if I put the code into the php it still outputs as plain text not html <meta http-equiv='refresh' content='5; url=./png.php?name=$nick' /> <?php $name = $_GET['name']; $img=imagecreatetruecolor(180,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$name); header('Content-Type: image/png'); imagealphablending($img,false); imagesavealpha($img,true); imagepng($img, "./img/name/$name.png"); imagedestroy($img); ?> Quote Link to comment Share on other sites More sharing options...
Solution scootstah Posted October 1, 2015 Solution Share Posted October 1, 2015 header('Content-Type: image/png');Because you're doing that. If you're not outputting the image then you can remove that line. Quote Link to comment Share on other sites More sharing options...
hyster Posted October 1, 2015 Author Share Posted October 1, 2015 thanks again scootstah, ur a star just encase any1 else has need for this , this is my final code to create a transparent png overlaid with text, rotate 90 deg and save to a folder <?php $nick = 'some source'; $img=imagecreatetruecolor(100,20); imagealphablending($img,false); $col=imagecolorallocatealpha($img,255,255,255,127); imagefilledrectangle($img,0,0,180,20,$col); imagealphablending($img,true); $degrees = 90; //rotate image $font=$_SERVER["DOCUMENT_ROOT"].'./Arial.ttf'; $color = imagecolorallocate($img, 0, 0, 0); imagettftext($img,11,0,5,14,$color,$font,$nick); imagealphablending($img,false); imagesavealpha($img,true); $img1 = imagerotate($img, $degrees, 0); imagepng($img1, "./img/name/$nick.png"); imagedestroy($img); ?> Quote Link to comment 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.