Code:
function createSaveJPGThumb($filename, $uploadfile, $newwidth, $quality = 80){
//resize image to max 800 wide
list($width, $height) = getimagesize($filename);
$newheight = $height * ($newwidth/$width);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$saved = imagejpeg($thumb,$uploadfile,$quality);
return $saved;
}
Comment