Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save a resized image to file

Status
Not open for further replies.

jebo100

Technical User
May 11, 2007
52
0
0
PH

i have followed this example from my manual and it worked well.

it displayed the imagejpeg($thumb) nicely.
now i wanted to save this new resized image to a file in my images directory, what command or procedure should i do?

<?php
$filename = 'test.jpg';
$percent = 0.5;
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb);
?>
 
just add the path and file name you want to use as the second argument to imagejpeg().

a quick visit to the manual would have worked wonders.
 
thanks jpadie!!!

i mislooked the protion of my manual saying this! :)
"bool imagejpeg ( resource image [, string filename [, int quality]] )"

thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top