Page 1 of 1

GD Image in a $var?

Posted: Wed Oct 08, 2003 4:17 pm
by Gen-ik
Probably been asked loads of times before but I've searched and can't find any answers so here goes...

I have a Class that uses GD to create images on-the-fly. Is it possible to store a created image in a $var in order to echo() at various points on the script? At the moment the image is being RETURNED from the Class and dumped into the page with a header("content-type") call.

I could create the image at each point it's needed but that's a bit slow.

I could save the image to the server and use that but it is only a temp image and creating,deleting,creating,deleting images all the time is a pain in the rear! This also applies to saving/loading from a Blob.

Posted: Wed Oct 08, 2003 4:39 pm
by pootergeist
Explain more pls.

echoing binary data directly to an <img src has an upper limit of around 1KB so is only useful for extremely small images - you'd need to target a script somewhere along the line really.
'on the fly' image creation is generally not such a great idea and you'd probably be doing yourself a favour if you can get a workaround system to do what you want - maybe use a crontab with a once per hour activation or a 404 handler.

as mentioned, more details would help.