rendered paste body //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// This is what you want //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// $imgs = getimagesize($image_path . $row['path']); if($width == 800 || $height == 800) { } else { $width = 0; $height = 0; if($imgs[0] > $imgs[1]) { //normal $width = 800; $height = 600; } else { //portrate $width = 600; $height = 800; } $im = imagecreatefromjpeg($image_path . $row['path']); $im2 = imagecreatetruecolor($width, $height); imagecopyresized($im2, $im, 0, 0, 0, 0, $width, $height, $imgs[0], $imgs[1]); imagejpeg($im2, $image_path . $row['path']); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////