B34ST Posted July 5, 2007 Share Posted July 5, 2007 Hi the following script gets some data(text) ad makes an image with the text: <?php header ("Content-type: image/png"); $img_handle = ImageCreate (600, 100) or die ("Cannot Create image"); $back_color = ImageColorAllocate ($img_handle, 0, 10, 10); $txt_color = ImageColorAllocate ($img_handle, 0, 100, 255); $vpos = 10; $hpos = 5; $i = 1; foreach ($score as $skill => $stats) { if ($skill) { if ($stats[2] == '') { $stats[2] = '0'; } ImageString ($img_handle, 20, $hpos, $vpos, "$skill $stats[2]", $txt_color); $vpos = $vpos + 15; if ($i == 5) { $vpos = 10; $hpos = $hpos + 150; $i = 0; } $i++; } } ImagePng ($img_handle); ?> The image has a black background which I would like to replace with a backgroud image(.gif) already created but so not know how this can be done. Also I would like to add icons(.gif images) to the left of each piece of text ($skill) but do not know if this is possible. Thanks in advance for any help Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/ Share on other sites More sharing options...
B34ST Posted July 5, 2007 Author Share Posted July 5, 2007 I have found out that I can use: $img_handle = ImageCreateFromPNG ("sig.png") or die ("Cannot Create image"); to solve the above problem but now I cannot figure out how to save the image rather than just outputting it to the browser. any ideas? Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-290873 Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 You need to use imagecreatefromgif() http://www.php.net/manual/en/function.imagecreatefromgif.php Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-290875 Share on other sites More sharing options...
Yesideez Posted July 6, 2007 Share Posted July 6, 2007 btw, the link I provided also lists the GD functions down the left side. Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-290876 Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 but now I cannot figure out how to save the image rather than just outputting it to the browser. any ideas? While you're reading the manual from Yesideez' link, have a read of imagepng() too, in particular the optional arguments. Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-291005 Share on other sites More sharing options...
B34ST Posted July 6, 2007 Author Share Posted July 6, 2007 Thanks for the advice although I had already tried the manual after your advice and reading again I have now achieved what I required. Link to comment https://forums.phpfreaks.com/topic/58583-solved-gd-library/#findComment-291541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.