DaveLinger Posted July 20, 2006 Share Posted July 20, 2006 [code]<?php$template = $_GET['template'];$nametext = $_GET['nametext'];$namefont = $_GET['namefont'];$namecolor = $_GET['namecolor'];$subtitle = $_GET['subtitle'];$subfont = $_GET['subfont'];$subcolor = $_GET['subcolor'];// Set the content-typeheader("Content-type: image/png");// Create the image$im = imagecreatefrompng('$template');// Create some colorsswitch ($namecolor){ case "black": $ncolor = imagecolorallocate($im, 0, 0, 0); break; case "white": $ncolor = imagecolorallocate($im, 255, 255, 255); break;}switch ($subcolor){ case "black": $scolor = imagecolorallocate($im, 0, 0, 0); break; case "white": $scolor = imagecolorallocate($im, 255, 255, 255); break;}// Add the textimagettftext($im, 20, 0, 23, 20, $ncolor, $namefont, $nametext);imagettftext($im, 12, 0, 23, 120, $scolor, $subfont, $subtitle);// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);imagedestroy($im);?>[/code]yields "The image “http://www.davessonicsite.com/sig/signature.php?template=shadow1.png&nametext=[PCR]Davers&namefont=Verdana.ttf&namecolor=black&subtitle=I%20pwn%20n00bs&subfont=Verdana.ttf&subcolor=black” cannot be displayed, because it contains errors."shadow1.png and Verdana.ttf are in the same folder as signature.php... any ideas? Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/ Share on other sites More sharing options...
zq29 Posted July 20, 2006 Share Posted July 20, 2006 [code]<?php$im = imagecreatefrompng('$template');//Change to...$im = imagecreatefrompng($template);//Or...$im = imagecreatefrompng("$template");//Because...$foo = "bar";echo $foo; //Displays "bar"echo "$foo"; //Displays "bar"echo '$foo'; //Displays "$foo"?>[/code] Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/#findComment-61091 Share on other sites More sharing options...
DaveLinger Posted July 20, 2006 Author Share Posted July 20, 2006 wow. I've been coding PHP for years now and I never realized that single quotes echo the name of the variable. dang.Thanks! Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/#findComment-61094 Share on other sites More sharing options...
zq29 Posted July 20, 2006 Share Posted July 20, 2006 No problem :) Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/#findComment-61095 Share on other sites More sharing options...
DaveLinger Posted July 20, 2006 Author Share Posted July 20, 2006 one last question (for now :P)the x aligning of the text is correct but my "name" is all the way at the top!http://www.davessonicsite.com/sig/imagetest.htmand my code says the name text should start at 23,20 not 23,0! Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/#findComment-61097 Share on other sites More sharing options...
zq29 Posted July 20, 2006 Share Posted July 20, 2006 The x and y coordinates define the basepoint of the first character (roughly the lower-left corner of the character). Not the top left. Link to comment https://forums.phpfreaks.com/topic/15159-image-creationtext-addition-help/#findComment-61105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.