Jump to content

Linking to php generated pngs (GD)


heavywater

Recommended Posts

Hello

 

I've spent the last few hours writing a small php file that creates a signature for Steam (a gaming platform) and saves it as a png. It basically just pulls the neceassary info and images from the user's Steam XML stream and uses GD to arrange it nicely. A link to an example is here.

 

Now, the trouble I have is that it saves the image as a .php file (it can be downloaded as a png but not linked to as one, images.php.png doesn't exist). I can navigate to the webpage and save as a png but for obvious reasons can't link to it as an image (making the forum signature part kind of hard to pull off).

 

Is there any easy way (I'm unspeakably bad with php) that I can save the php graphic as a PNG to an external page (for example /sig_name.png or /images.php?id=name.png)?

 

Thanks for any help :)

Link to comment
Share on other sites

Im thinking one of 2 things,

  One: look into base_64 encode/decode()

  Two: (maybe the better of bets) is look into sending a header out with the PHP thats specific to PNG at the top of the script, so when its done rendering it should to the browser be recognized as a png and not a php (despite the file name at the time). There is also a way to likely "copy" the image from the temp/tmp location its being saved to when it originally renders to a specific folder on the server. From there it can be stored and used in img src=..

 

don't ask me how right now as I am super tired and even in knowing what you want to do is possible, I am to fried to think of how to do it right now, I am kinda posting here through out the site in a means to wind myself down to sleep.. :)

anyway hope what I did say makes sense and helps at the least some even though its not a straight forward answer. I can say it is possible though. Look up "Watermarking Images" Im sure from that you can get a piece to the puzzle I am talking about that will essentially create a new image and store it somewhere else other than the temp..

Link to comment
Share on other sites

There is also a way to likely "copy" the image from the temp/tmp location its being saved to when it originally renders to a specific folder on the server. From there it can be stored and used in img src=..

Yup, I was hoping for something along these lines but didn't have much luck. I'm kind of surprised there's nothing about this in GD, how do people normall link to the images?

 

Anybody else got any ideas?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.