I noticed that Message-ID:
<42***********************@newsreader.inode.at> from Martin Brunner
contained the following:
It should be very simple (just login and upload) but it should be able
to rezise pictures. You specify a value for the max height and max width
and depending if the hight or width is more the picture will be rezised
so that it fits into the gallery thumnails even if it was taken 90°
rotated.
Is there such a script available somewhere?
Not a gallery script, but my upload script does what you want
<?php
$path = "images/main/";
$thumbpath = "images/thumb/";
$thumbnail_width=50;
$mainpath="images/main/";
$main_width=450;
$max_size = 2000000;
$filename="";
if (!empty($_FILES['userfile'])) {
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
if ($_FILES['userfile']['size']>$max_size)
{ echo "The file is too big<br>\n"; exit; }
if($_FILES['userfile']['type']=="image/gif"){
$createfunction="imagecreatefromgif";}
else{$createfunction="imagecreatefromjpeg";}
if (($_FILES['userfile']['type']=="image/gif") ||
($_FILES['userfile']['type'])=="image/pjpeg" ||
($_FILES['userfile']['type']=="image/jpeg")) {
//check if file already uploaded
//if (file_exists($thumbpath ."s_".
$_FILES['userfile']['name'])) { echo "The file already exists<br>\n";
exit; }
//make a copy of original file
//$res = copy($_FILES['userfile']['tmp_name'], $path .
//$_FILES['userfile']['name']);
//create thumbnail image
$src_img = $createfunction($_FILES['userfile']['tmp_name']);
$new_w = $thumbnail_width;
$new_h = imagesy($src_img)/(imagesx($src_img)/$new_w);
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_w,
$new_h, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, $thumbpath
.."s_".$_FILES['userfile']['name'], 100);
//create big image
if(imagesx($src_img)>450){
$new_w = $main_width;
$new_h = imagesy($src_img)/(imagesx($src_img)/$new_w);
$dst_img = imagecreatetruecolor($new_w,$new_h);
$res=imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,
$new_w, $new_h, imagesx($src_img), imagesy($src_img));
imagejpeg($dst_img, $path ."b_".
$_FILES['userfile']['name'], 50);
$notify = "Main image resampled";
}
else{
$res = copy($_FILES['userfile']['tmp_name'], $path
.."b_".
$_FILES['userfile']['name']);
$notify = "Main image not resampled";
}
if (!$res) { echo "<h2>Upload failed!</h2><br>\n"; exit;
}
else { echo "<h2>Upload sucessful!</h2>\n";
}
$filename=$_FILES['userfile']['name'];
printf("<strong>Main :
</strong>%sb_%s<br>\n",$path,$filename);
printf("<strong>Thumbnail :
</strong>%ss_%s<br>\n",$thumbpath, $filename);
echo "Original File Size:
".$_FILES['userfile']['size']." bytes<br>\n";
echo "File Type: ".$_FILES['userfile']['type']."<br>\n";
echo "$notify.<br>\n";
}
else { echo "<span class=\"indent10bold\">Please use a
..jpg or a .gif file</span><br>\n"; exit; }
printf("<span class=\"indent10bold\">Image Thumbnail:
</span><br><br><span class=\"indent10bold\"><img
src=\"%ss_%s\"alt=\"%s\"></span><br>",$thumbpath,$filename,$_POST['alt_text']);
imagedestroy($src_img);
imagedestroy($dst_img);
}
//end of image upload
//variables for insertion into product table
$thumb_url="s_".$filename;
$main_url="b_".$filename;
}
?>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs
http://www.ckdog.co.uk/rfdmaker/