Gobiggi Posted August 15, 2006 Share Posted August 15, 2006 k ive been looking for help in loads of places, and got some of it, so ive got this far but my script still doesn't work, all i get is a red X,what i am aiming for is to create images like this:[img]http://i111.photobucket.com/albums/n148/Gobiggi/Gobiggi.gif[/img]but what i need is the last pixel of the last word staying in the same place for every text that is entered, so far my script is:[code]<?php header("Content-type: image/png"); $string = urldecode($_GET['text']); $im = imagecreatefrompng("template.png"); $fontsize = 10; $fontsize2 = 12; $angle = 25; $font = "visitor1.ttf"; $textColor = imagecolorallocate($im,255,255,255) $textColor2 = imagecolorallocate($im,0,0,0); array imagettfbbox(12,25,$font,$string); imagettftext($im, $fontSize2, 25, 291, -1, $textColor2, $font, $string); imagettftext($im, $fontSize, 25, 290, 0, $textColor, $font, $string); imagepng($im); imagedestroy($im); ?> [/code]but i really think ive made loads of mistakes that i cannot find,please help me do this. Link to comment https://forums.phpfreaks.com/topic/17689-image-generation/ Share on other sites More sharing options...
Barand Posted August 15, 2006 Share Posted August 15, 2006 try[code]<?php header("Content-type: image/png"); $string = urldecode($_GET['text']); $im = imagecreatefrompng("template.png"); $height = imagesy($im); $width = imagesx($im); $fontsize = 10; $fontsize2 = 12; $angle = 25; $font = "visitor1.ttf"; $textColor = imagecolorallocate($im,255,255,255); $textColor2 = imagecolorallocate($im,0,0,0); $array = imagettfbbox($fontsize2,$angle,$font,$string); $ypos = $height - 5; // baseline of text $xendpos = $width-10; // text ends 10px from right $textwidth = $array[2] - $array[0]; $xpos = $xendpos - $textwidth; imagettftext($im, $fontSize2, $angle, $xpos+1, $ypos-1, $textColor2, $font, $string); imagettftext($im, $fontSize, $angle, $xpos, $ypos, $textColor, $font, $string); imagepng($im); imagedestroy($im); ?> [/code] Link to comment https://forums.phpfreaks.com/topic/17689-image-generation/#findComment-75391 Share on other sites More sharing options...
Gobiggi Posted August 15, 2006 Author Share Posted August 15, 2006 Wow! Thanks man,but i still have one problem, when i type:img.php?text=Gobiggino text appearsbut thanks for the above text, and hopefully you can help me overcome this problem, because im a total php noob, Link to comment https://forums.phpfreaks.com/topic/17689-image-generation/#findComment-75420 Share on other sites More sharing options...
Gobiggi Posted August 16, 2006 Author Share Posted August 16, 2006 c'mon nearly an hour and no replies, i really want to get this script done so i can get it out of the way Link to comment https://forums.phpfreaks.com/topic/17689-image-generation/#findComment-75453 Share on other sites More sharing options...
Barand Posted August 18, 2006 Share Posted August 18, 2006 Works better if both fontsizes are the same[code]<?php header("Content-type: image/png"); $string = urldecode($_GET['text']); $im = imagecreate(100, 120); // as I don't have your template image' $height = imagesy($im); $width = imagesx($im); $fontsize = 12; $fontsize2 = 12; $angle = 25; $font = "c:/windows/fonts/arialbd.ttf"; // used a font on my pc here $bg = imagecolorallocate($im, 228,228,228); $textColor = imagecolorallocate($im,255,255,255); $textColor2 = imagecolorallocate($im,0,0,0); $array = imagettfbbox($fontsize2,$angle,$font,$string); $ypos = $height - 50; // baseline of text $xendpos = $width-10; // text ends 10px from right $textwidth = $array[2] - $array[0]; $xpos = $xendpos - $textwidth; imagettftext($im, $fontsize2, $angle, $xpos+1, $ypos-1, $textColor2, $font, $string); imagettftext($im, $fontsize, $angle, $xpos, $ypos, $textColor, $font, $string); imagepng($im); imagedestroy($im); ?>[/code] Link to comment https://forums.phpfreaks.com/topic/17689-image-generation/#findComment-76532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.