Jump to content

Dynamic image creation question...


DaveLinger

Recommended Posts

so I have this dynamic image creation script, but obviously when people go to save it it tries to save it as .php instead of the png that it is, and many forums do not allow them to use these images because the extension is php... is there any way to get it to output to .png apart from saving each person's generated image to the server or making php process any .png image files?
Link to comment
Share on other sites

Only thing I can think of is providing a link next to the image.  When they click that link create the image and save it into a temp folder and allow them to save that image.

Clear you temp folder of images older than 1 hour every hour (or day or what ever) with a cron job.
Link to comment
Share on other sites

[quote author=onlyican link=topic=104202.msg415459#msg415459 date=1155566243]
U can use header(); function setting the MIME types to png instead of standard php
This should work well
[/quote]

I already do that, but the extension of the file is still php, so thats what the browser tries to save it as.
Link to comment
Share on other sites

Well unless you also want to parse png files in PHP here is how you do it.

The place in apaches conf where you set which extensions should be parsed in PHP put png, jpg, gif
and write image code in png to return a png file which can be saved.

So you see you cant do it unless you wanna parse image files which only the server admin can do which i guess is not you
Link to comment
Share on other sites

I just found out that, In IE when u use save picture as it saves as the type not .php and also when you save the document it saves a web page with the pic.
I dint use that code from GD but another script which takes pictures from MySQL
Link to comment
Share on other sites

You can also create an Object buffer ,

Imagepng($im,'',50);
ob_start();
Imagepng($im,'',50);
$image_data = ob_get_contents(); // get the buffer into a variable
ob_end_clean(); // discard the buffer 
ImageDestroy ($im);


then use $image_data as you like.

Cheers,

ECD @ Tangaza.com
(www.tangaza.com)

Link to comment
Share on other sites

  • 2 months later...
This is exactly the same problem I'm having.  The person who replied last said something about using the object buffer, but I'm really not sure exactly how this helps. 

I know I call the image using the php script that creates the image as the image source, but I'd like the saveas option to have a .png instead of .php (for browsers like Firefox that don't check the filetype when doing the saveas, and instead just check the src="image.php").

How do I do this?
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.