$filename = $_FILES['myfile']['tmp_name'];
list($width, $height) = getimagesize($filename);
if ($width>400 || $height >400) {
if ($width > $height) {
$newHeight = (400/$width)*$height;
$newWidth = 400;
}
else {
$newWidth = (400/$height)*$width;
$newHeight = 400;
}
}
else {
$newWidth = $width;
$newHeight = $height;
}
$thumb = imagecreate($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output
imagejpeg($thumb);
move_uploaded_file($thumb, $absolute_path . "/" . $id . "." . $ext) or die("fejl");
?>
Sådan her muligvis...
Det er sent, så ingen garanti for at der ikk er syntax fejl..
men mere info her:
http://dk2.php.net/manual/da/function.imagecopyresized.php