PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm trying to create a class that will create an image from text. I've got it all working up to the point where it goes to actually display the image. Here's how I'd like the PHP file to look that calls the class
function Show_Image()
{
header("Content-type: image/png"); //Set the header
imagePNG($this->Image); //Send the image to the browser
imageDestroy($this->Image); //throw away our canvas
}
My question is how can I call a class function so that it sends the headers and such as many people have done using something like:
function Show_Image()
{
header("Content-type: image/png"); //Set the header
imagePNG($this->Image); //Send the image to the browser
imageDestroy($this->Image); //throw away our canvas
}
With the setup you mentionted below, I wasn't able to display the image on the blah.php page and I'm not sure why. I'm able to right click on the broken image icon and go to view image, but I get a "cannont modify header error" followed by the image jibberish (raw data).
If I follow the setup you mentioned, the problem I'm going to run into is that from the blah.php page (blah.html) I now have no way of changing the text, font size or anything else on the fly as it will now be hardcoded into the image_generator.php file. I'd like to later be able to use this class to create images based on data thats pulled from a database. and so I'd have to be able to specify the objects attributes in the blah.php page. Passing items via GET is out of the question due to design criteria
and in the class for the Show_image function is the only place where I send the browser any info and nothing is printed in the class by any echo commands:
function Show_Image()
{
header("Content-type: image/png"); //Set the header
imagePNG($this->Image); //Send the image to the browser
imageDestroy($this->Image); //throw away our canvas
}
But still the images doesn't show, any ideas?
Paul
include ("text2image-class.php");
$image = new Text2Image();
$image->Set_Text ( "print me" );
$image->Set_Font_Type ( "luximbi" );
$image->Set_Font_Size ( 12 );
$image->Create_Image();
$image->Show_Image();
So that I could at least verify that my class is working, and something is screwed up... When I browse to image_generator.php I get:
Warning: Cannot modify header information - headers already sent by (output started at
.................../text2image-class.php:508) in
............../text2image-class.php on line 503
‰PNG the png image jibberish
line 508 is the very last line in my class file and line 503 is