Forum Moderators: coopster

Message Too Old, No Replies

how can i save the output file on the server

         

lindajames

7:03 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



Hi,

I have the following code that generates a thumbnail using GD, but the thing is it does it on the fly, can anyone please tell me how i can use it to save the file first and then display it.

$image = $_GET['src'];
$scale = 20;

$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$type = $size[2];
$scale = $scale/100;
$newwidth = round($width*$scale);
$newheight = round($height*$scale);

header ("Content-type: image/jpeg");
$src = imagecreatefromjpeg("$image");
$im = imagecreate($newwidth,$newheight);
imagecopyresized($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($im);
imagedestroy($im);

Cheers

Philosopher

7:23 pm on Jun 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should simply be able to add the needed arguments to your imagejpeg command. This will output it to the browser and a file.

Here is an example from a script I am running

ImageJPEG($pic,path_to_your_folder/filename.jpg);

lindajames

7:45 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



i tried that and i also tried

imagejpeg($im,img/thumbs/test.jpg);

but it doesnt seem to save it still

Philosopher

8:03 pm on Jun 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what are the permissions for your "thumbs" directory? You may need to change them to allow the directory to be written to.

lindajames

8:06 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



its CHMOD'ed to 777

lindajames

9:54 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



any one?

lindajames

10:19 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



SORRYYY.... my mistake. it does actually work. i was just executing the wrong file on my browser. i had temp.php and temps.php

thanx for all your help