GD Image in a $var?

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!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

GD Image in a $var?

Post 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.
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post 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.
Post Reply