DaveLinger Posted June 30, 2006 Share Posted June 30, 2006 so I have a database with a bunch of "missions", and for each one I have lots of stats, including processor, data bus, etc. I'd like to retrieve these variables (not a problem) then put them in a certain place on my template image (problem). I have GD on my server for image manipulation, but have no explerience with it. can someone explain to me how to put the contents of a variable containing text into an image using GD?Here's an example:[img]http://www.pcritics.com/images/other/example.JPG[/img]And my template:[img]http://www.pcritics.com/images/other/template.JPG[/img] Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/ Share on other sites More sharing options...
zq29 Posted June 30, 2006 Share Posted June 30, 2006 Here's an example from the manual, using the function imagettftext() :[code=php:0]<?php// Set the content-typeheader("Content-type: image/png");// Create the image$im = imagecreatetruecolor(400, 30);// Create some colors$white = imagecolorallocate($im, 255, 255, 255);$grey = imagecolorallocate($im, 128, 128, 128);$black = imagecolorallocate($im, 0, 0, 0);imagefilledrectangle($im, 0, 0, 399, 29, $white);// The text to draw$text = 'Testing...';// Replace path by your own font path$font = 'arial.ttf';// Add some shadow to the textimagettftext($im, 20, 0, 11, 21, $grey, $font, $text);// Add the textimagettftext($im, 20, 0, 10, 20, $black, $font, $text);// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);imagedestroy($im);?>[/code] Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51182 Share on other sites More sharing options...
DaveLinger Posted June 30, 2006 Author Share Posted June 30, 2006 thanks! Just a few questions...how would I use my own image instead of a filled white rectangle? ;Dalso, in "imagettftext($im, 20, 0, 10, 20, $black, $font, $text);", are 20,0,10,20 the co-ordinates for the location of the text or what? ??? Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51186 Share on other sites More sharing options...
Orio Posted June 30, 2006 Share Posted June 30, 2006 20- size0- angle10- x-coord20- y-coord[url=http://www.php.net/manual/en/function.imagettftext.php]imagettftext()[/url]Orio. Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51191 Share on other sites More sharing options...
DaveLinger Posted June 30, 2006 Author Share Posted June 30, 2006 [hug]now what about using my own image as the background instead of the white block? Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51194 Share on other sites More sharing options...
zq29 Posted June 30, 2006 Share Posted June 30, 2006 You could use [url=http://www.php.net/imagecreatefromjpeg]imagecreatefromjpeg()[/url]All of the GD functions can be found at php.net/gd for future reference! :) Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51197 Share on other sites More sharing options...
DaveLinger Posted June 30, 2006 Author Share Posted June 30, 2006 Thanks!(these new smileys are like satanic) Link to comment https://forums.phpfreaks.com/topic/13291-how-to-create-dynamic-images-by-using-text-based-variables/#findComment-51202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.