Jump to content

Slight problem with GD and PNG file support


magnav0x

Recommended Posts

I have an issues when generating PNGs. The actual images come up just fine...no problem there, but if I right click on the generated image and try to save it, it only gives me the option of saving it as a .bmp in IE. In Firefox, it won't even allow me to download the image....well I can, but it won't be a valid image. Also, in IE when I right click on the generated images it says "Not Available" next to the File Type descriptor. Is this a common problem or something I may be doing? I basically want the users to be able to right click on the generated image and actually save it as a PNG image.

I'm using:
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);

Thanks in advance guys!
Link to comment
Share on other sites

[!--quoteo(post=365788:date=Apr 17 2006, 07:48 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Apr 17 2006, 07:48 PM) [snapback]365788[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This should be OK... But where is the image resource ($im)?

Also note that your script actually outputs an image, meaning that you shouldn't mix it with HTML or whatever, like.
[/quote]

Using a standard
$im = imagecreatefrompng("whatever.png");

No HTML is used on the page that is displaying the generated image at the moment. The only thing displayed on the page is generated by imagepng()
Link to comment
Share on other sites

[!--quoteo(post=365804:date=Apr 17 2006, 08:19 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 17 2006, 08:19 PM) [snapback]365804[/snapback][/div][div class=\'quotemain\'][!--quotec--]
have you tried imagejpeg or imagegif to see if ie and firefox just don't like PNG?

Also, how is the file referenced? is it <img src="image.jpg"> or <img src="image.php?id=234"> or the like? You might have to cloak your php with something like .htaccess
[/quote]

I haven't tryed using the gif or jpg functions, because the script I wrote, relies on the outputed file to be PNG (8bit). I may mess with them tomorrow though out of curiosity, just to see if IE and FF throw fits with them as well. I already had a .htaccess file setup for the PNG script and I'm not calling the image via HTML at all.

[a href=\"http://www.somewhere.com/image.png\" target=\"_blank\"]http://www.somewhere.com/image.png[/a] (which would execite...image.php as defined by the .htaccess file)

When the script is run it does it's thing and generates the PNG image to the screen, that's it. No overhead at all on it.
Link to comment
Share on other sites

Ok, I pretty much think I figured out what exactly is causing the problem. In short the script is suppose to let the user upload a JPG and the script then does some "modifying" on the image and regenerates it as a PNG (must be 8bit).

Scenario 1:
I uploaded a JPG image to the same directory as the script and just hard coded that images name into the script. When it generates the PNG everything is fine and dandy, I can save the image as PNG in IE and FF.

Scenario 2:
Use HTML form that allows the user to upload an image. The form calls the said PHP script and uses the file that they uploaded in the script, but can not save as a PNG in IE or FF.

All morning I've been trying different things and it seems that as long as the PHP script is being referenced by a HTML form, it will NOT work. Can anyone think of a work around for this? I've tryed making the HTML form submit to a stand alone PHP script that would upload the file and store the name of the file in a session and then use HEADER to redirect to the actual generation script and then use the session variable of the file name, but that is a no go as well.
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.