( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php $thumb_width = 800;
list($width, $height) = getimagesize($thepicha);
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $thumb_width;
$newheight = $thumb_width/$imgratio;
}else{
$newheight = $thumb_width;
$newwidth = $thumb_width*$imgratio;
}
$resized_img = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageJpeg ($resized_img,"$thepicha");
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
?>