airportmarc Posted November 7, 2009 Share Posted November 7, 2009 Hey all, I am having problems with modifying an image from a pre-created base template. I am trying to add a single number tothe image but I am having no luck. This is the first time I am playing with the GD library. This is the code that I have to create the image: foreach($outputArray as $tempArray){ $text = tempArray[number] $im = imagecreatefrompng('XX/todayBlank.png'); $black = imagecolorallocate($im, 0, 0, 0); $x = 5; $y = 7; imagettftext($im, 10, 0, $x, $y, $black , 'Arial' ,$text); $output .= "<div class='tableContentRow "> <div class='tableData' style='float: left; width: 60%;'>tempArray[fullName]</div> <div class='tableData' style='float: left; width: 40%;'>" . imagepng($im) . "</div> <div class='clear'></div> </div>"; } print $output; I think it has something to do with the fact that I am outputing an image to HTML and saving it in $output. Any ideas on how I can create a custom number for each iteration of the loop? Also, I know I need to send a header, but where would I do that? All the best, Marc Link to comment https://forums.phpfreaks.com/topic/180623-creating-an-image/ Share on other sites More sharing options...
seanlim Posted November 7, 2009 Share Posted November 7, 2009 yep, you cannot output the image into a html file directly. use: <div class='tableData' style='float: left; width: 40%;'><img src='pngImage.php?number=".$number."'></div> and in pngImage.php, place your code to create the png image. at the start of the script, place the header which sets the mime-type of the file. and at the end, simply call imagepng($im); Link to comment https://forums.phpfreaks.com/topic/180623-creating-an-image/#findComment-952943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.