Interesting code.
Hhowever, it's resizing pictures to the limit set for intermediate pictures (in my case 400).
I modified the code a bit to work with vertical pictures too (height>width) and changed the 'picture_width' value with 'max_upl_width_height' which is set to 800, so I am supposed to get 800x600 or 600x800 pictures, depending on the case.
However, pictures are still generated using 400 pixels not 800, i don't understand why.
Can anybody look into this? Here's the code:
// Resize picture automatically if it's too big - added by Hal9000
if (eregi ("\.jpe?g$", $uploaded_pic)) {
$imgOld = imagecreatefromjpeg($uploaded_pic);
$width = imagesx($imgOld);
$height = imagesy($imgOld);
if ($width >= $height && $width > $CONFIG['max_upl_width_height']) {
$height = ($CONFIG['max_upl_width_height']/$width)*$height;
$width = $CONFIG['max_upl_width_height'];
$imgNew = ImageCreateTrueColor($width,$height); //requires GD 2.0
ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld)); //requires GD 2.0
ImageJpeg($imgNew,$uploaded_pic);
Imagedestroy($imgNew);
}
if ($width < $height && $height > $CONFIG['max_upl_width_height']) {
$width = ($CONFIG['max_upl_width_height']/$height)*$width;
$height = $CONFIG['max_upl_width_height'];
$imgNew = ImageCreateTrueColor($width,$height); //requires GD 2.0
ImageCopyResampled($imgNew,$imgOld,0,0,0,0,$width,$height,imagesx($imgOld),imagesy($imgOld)); //requires GD 2.0
ImageJpeg($imgNew,$uploaded_pic);
Imagedestroy($imgNew);
}
}
Thanks!
hal