php - Dynamic Text on Image Suddenly Not Working -


so i'm creating site returns quotes based on input. want quotes returned text on picture, found guide @ http://jonlim.ca/2011/11/creating-an-image-with-dynamic-text-in-php/ me.

i'm running xampp test php , code looks like...

<?php header("content-type: image/png"); /*$string = $_get['days'];*/ $im = imagecreatefrompng("twainpen.png"); imagealphablending($im, false); imagesavealpha($im,true); $transparent = imagecolorallocatealpha($im, 255, 255, 255, 127); imagepng($im); $black = imagecolorallocate($im, 0, 0, 0); $font = 'daniel.ttf';  $initialx = '153'; $initialy = '35'; $increasey = '23';  $fontsize = '16'; $fontrotation = '0';  $firstline = 'what mean'; $secondline = 'there ' . $string . ' days until'; $thirdline = 'christmas?! am'; $fourthline = 'i supposed until'; $fifthline = 'then? wait?! am'; $sixthline = 'not patient man!';  //imagestring($im, $font, $px, 20, $string, $black); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy, $black,         $font, $firstline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+$increasey,  $black, $font, $secondline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*2), $black, $font, $thirdline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*3), $black, $font, $fourthline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*4), $black, $font, $fifthline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*5), $black, $font, $sixthline); imagepng($im); imagedestroy($im); ?> 

this code identical guide , frustrating thing when last working on few weeks ago got work, after started futzing around else came , wouldn't work anymore (all happens picture shows without text on it). i'm betting solution dumb mistake i'm making, not sure is. font in same folder code picture.

any or thoughts can given appreciated! thank you.

first have remove line 8 . outputs image before adding text. set path font .
described here :
http://php.net/manual/en/function.imagettftext.php

depending on version of gd library php using, when fontfile not begin leading / .ttf appended filename , library attempt search filename along library-defined font path.



<?php header("content-type: image/png"); $string = $_get['days']; $im = imagecreatefrompng("twainpen.png"); imagealphablending($im, false); imagesavealpha($im,true); $transparent = imagecolorallocatealpha($im, 255, 255, 255, 127); $black = imagecolorallocate($im, 0, 0, 0); $font = './daniel.ttf';  $initialx = '153'; $initialy = '35'; $increasey = '23';  $fontsize = '16'; $fontrotation = '0';  $firstline = 'what mean'; $secondline = 'there ' . $string . ' days until'; $thirdline = 'christmas?! am'; $fourthline = 'i supposed until'; $fifthline = 'then? wait?! am'; $sixthline = 'not patient man!';  //imagestring($im, $font, $px, 20, $string, $black); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy, $black,         $font, $firstline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+$increasey,  $black, $font, $secondline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*2), $black, $font, $thirdline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*3), $black, $font, $fourthline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*4), $black, $font, $fifthline); imagettftext($im, $fontsize, $fontrotation, $initialx, $initialy+($increasey*5), $black, $font, $sixthline); imagepng($im); imagedestroy($im); ?> 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -