Jump to content


Photo

Dynamic image creation question...


  • Please log in to reply
7 replies to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 14 August 2006 - 01:20 PM

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?
http://www.DaveLinger.com
dave at linger dot com

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 14 August 2006 - 02:26 PM

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.
follow me on twitter @PHPsycho

#3 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 14 August 2006 - 02:37 PM

U can use header(); function setting the MIME types to png instead of standard php
This should work well
Tell me the problem, I will try tell you the solution

#4 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 14 August 2006 - 04:18 PM

U can use header(); function setting the MIME types to png instead of standard php
This should work well


I already do that, but the extension of the file is still php, so thats what the browser tries to save it as.
http://www.DaveLinger.com
dave at linger dot com

#5 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 14 August 2006 - 04:47 PM

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
I am a PHP Guru, ask me questions if you want to

#6 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 15 August 2006 - 07:08 AM

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
I am a PHP Guru, ask me questions if you want to

#7 tangazacom

tangazacom
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 15 August 2006 - 08:16 AM

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)


ECD @ tangaza
www.tangaza.com

#8 dwees

dwees
  • Members
  • PipPipPip
  • Advanced Member
  • 47 posts
  • LocationUnited Kingdom

Posted 17 October 2006 - 03:58 PM

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?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users