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
https://forums.phpfreaks.com/topic/17507-dynamic-image-creation-question/
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.
[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.
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
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)

  • 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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.