Dynamic Image Saving

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
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Dynamic Image Saving

Post by cesarcesar »

I have a page thats sole function is to generate a dynamic image. When the image is loaded on screen, the only code within the source code body is

Code: Select all

<img alt="my alt tag" src="http://www.my-site.com/get.php?image_id=1" />
When i right click on the image and try a "save as.." the suggested file name is *get.php.jpg*. So good so far.

What i want to do is load this page in the buffer or cache, then rename and save the generated image to a designated folder on my server, instead of displaying it. Once i save the image, i will just header() to another page for display. Is there a way to do what i describe?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Yes.

Code: Select all

imagejpeg($imageResource, '/path/where/you/want/to/store.jpg');
Of course you'll need GD library configured with php, and if the image is not a JPEG, you can use imagepng(), or imagegif().
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply