modchamp Posted November 10, 2008 Share Posted November 10, 2008 Ok well I've got a signature generator that I use to make and allow other people to make matching signatures for a forum. Anyways it uses the GD Library and it doesn't actually save to a file, just shows the output. When I try to download the png image with IE it has me save it as a bmp, but it saves just fine. When I try in FF it let's me save it as a png, but when I open the image I saved it's something totally different, not the right image (looks like leftovers from old signatures I've made). Anyways I'm just wondering if it's possible to save these png's on the fly or if I need to have them saved temporarily to my web host. Thanks, -modchamp Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/ Share on other sites More sharing options...
Barand Posted November 10, 2008 Share Posted November 10, 2008 imagepng ($img, 'filename'); Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687013 Share on other sites More sharing options...
modchamp Posted November 10, 2008 Author Share Posted November 10, 2008 Yes I know that, but I'm wondering if I can have it be able to be downloaded without having to save the image to the web host. And if I did it that war, if say 2 people did it within relatively short time of each other the 1st person could very easily download the 2nd person's, so I'd want to have it throw a variable in the filename. Anyways, I just want to know if it's possible to download the image without having to save it to the web host. Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687140 Share on other sites More sharing options...
DarkWater Posted November 10, 2008 Share Posted November 10, 2008 My personal guess is that you are not sending the correct headers and it's messing up the file. Can we please see the code? And there's no way for the 1st person to download the 2nd person's, by the way. =/ Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687157 Share on other sites More sharing options...
modchamp Posted November 10, 2008 Author Share Posted November 10, 2008 I was saying, if I had it save to a filename, each time someone ran it it would overwrite that file, so therefore 2 people could download the same one. Anyways here's the gist of my code: <? header("Content-Type: image/png"); if ( $yes == "ours" ) { If ( $raced == "Signature 1") { $im = imagecreatefrompng("./images/01.png"); } } imagestring($im, $font2, $leftTextPos, $height-100, "$text", $color); imagepng($im); imagedestroy($im); Obviously not all of my code, but that should be enough of it. Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687176 Share on other sites More sharing options...
Barand Posted November 10, 2008 Share Posted November 10, 2008 try something like $im = imagecreate(50,50); $bg = imagecolorallocate($im,0,0,0); $tc = imagecolorallocate($im, 255,255,0); imagestring($im, 5,15, 15, 'XXX', $tc); header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=x.png"); imagepng($im); imagedestroy($im); Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687216 Share on other sites More sharing options...
modchamp Posted November 10, 2008 Author Share Posted November 10, 2008 Ok, that works just great, except when I click submit on the previous page (the form you fill out) it just pops up asking to download the file, it doesn't display the image like it was before. Any way to do that? Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687218 Share on other sites More sharing options...
Barand Posted November 10, 2008 Share Posted November 10, 2008 <a href='image.php?download=1' title='Click to download'><img src='image.php' ></a> image.php <?php $download = isset($_GET['download']) ? 1 : 0; $im = imagecreate(50,50); $bg = imagecolorallocate($im,0,0,0); $tc = imagecolorallocate($im, 255,255,0); imagestring($im, 5,15, 15, 'XXX', $tc); if ($download) { header("content-type: application/octet-stream"); header("content-disposition: attachment; filename=x.png"); } else header ("content-type: image/png"); imagepng($im); imagedestroy($im); ?> Link to comment https://forums.phpfreaks.com/topic/132184-solved-saving-images-created-with-gd-library/#findComment-687230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.