<?
$fn = $_FILES['file']['tmp_name'];
$size = getimagesize($fn);
$ratio = $size[0]/$size[1]; // width/height
if( $ratio > 1) {
$new_width = 500;
$new_height = 500/$ratio;
}
else {
$new_width = 500*$ratio;
$new_height = 500;
}
list($width, $height) = getimagesize($fn);
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($fn);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, "z2.jpg", 100);
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" />
</form>
Tidak ada komentar:
Posting Komentar