View Single Post
Old September 6th, 2007, 1:19 PM   #3 (permalink)
FredFredrickson
Senior Member
Super #1
 
FredFredrickson's Avatar
 
Joined in Nov 2003
Lives in New Hampshire
1,145 posts
Gave thanks: 3
Thanked 20 times
Code:
$size = 150; //Desired width. Height will be scaled Automatically.
$quality = 70; //Desired Quality of Resized Image out of 100.
$pathtoimage = "/path/to/image.jpg"; Path or URL to the picture
$pathtonewimage = "/path/to/newimage.jpg"; Your PATH TO resized picture

$src = ImageCreateFromJPEG($pathtoimage);

if(imagesx($src)>$size)
{
	$xsiz = $size;
}
else
{
	$xsiz = imagesx($src);
}

$ysiz = (((imagesy($src))*($xsiz))/imagesx($src));
						
$thumbnew = imagecreatetruecolor($xsiz, $ysiz);
imagecopyresampled($thumbnew,$src,0,0,0,0,$xsiz,$ysiz,imagesx($src),imagesy($src));
						
imagejpeg($thumbnew, $pathtonewimage, $quality);
__________________
The Coding Blog - Follow along as we discover and discuss everything it takes to code an entire website, start to finish! [Latest Entry: 4/4/08 - Starting a Website]
FredFredrickson is offline   Reply With Quote