Image From PHP Function
Posted: Mon Apr 26, 2010 5:07 am
Hey all. I have a problem I can't seem to solve! I have a function that adds text to an image. It works fine when I run it by itself but when I run it from a PHP page which has all the <html> tags and such it just prints out text. I believe this is because of the <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> that it is run inside of.
So my question is, how do I call my function?
Here is the function that works by itself.
So my question is, how do I call my function?
Here is the function that works by itself.
Code: Select all
<?
function createLottoTicket($ticketNumber) {
header ("Content-type: image/pjpeg");
$stringImage = (string)$ticketNumber;
$font = 5;
$im = ImageCreateFromjpeg("./images/lottoTicket.jpg");
$background_color = imagecolorallocate ($im, 255, 255, 255); //white background
$text_color = imagecolorallocate ($im, 0, 0,0);//black text
imagestring ($im, $font, 24, 40, $stringImage, $text_color);
imagejpeg ($im);
}
createLottoTicket(10101);
?>