heavywater Posted March 25, 2011 Share Posted March 25, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/231654-linking-to-php-generated-pngs-gd/ Share on other sites More sharing options...
monkeytooth Posted March 25, 2011 Share Posted March 25, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/231654-linking-to-php-generated-pngs-gd/#findComment-1192101 Share on other sites More sharing options...
heavywater Posted March 25, 2011 Author Share Posted March 25, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/231654-linking-to-php-generated-pngs-gd/#findComment-1192127 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2011 Share Posted March 25, 2011 The second parameter of imagepng() is the file name to save the image as - filename The path to save the file to. If not set or NULL, the raw image stream will be outputted directly. Quote Link to comment https://forums.phpfreaks.com/topic/231654-linking-to-php-generated-pngs-gd/#findComment-1192130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.