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);