hi dudes,
i'd like to disable the full size feature and staying only with the intermediate size which i will setup a maximum width.
has anyone already done something like this?
i wan't it to have something like the actually fotologs. no matter how big you upload you picture it always gets the maximum size (if bigger than it).
example 1:
i have a 2048 x 1600 photo.
the gallery maximum width is 640 then i get a error.
so i must resize the picture myself and send it again.
example 2:
2048 width photo.
intermadiate picutre enabled with 640 maximum width.
i get a thumb, the normal size and the real one.
my desire:
no matter the size of the photo (pixels)
upload it and if it is bigger than 640x480 resizes it proporsionally.
generate the thumb.
got it?
thanks!
not tested yet but i guess it has solved my problem:
http://forum.coppermine-gallery.net/index.php?topic=464.0
just a improvement:
if (eregi ("\.jpe?g$", $uploaded_pic)) {
$imgOld = imagecreatefromjpeg($uploaded_pic);
$width = imagesx($imgOld);
$height = imagesy($imgOld);
$wmax = 640; //defined here because i'm not sure where it is
$hmax = 480;
$quality = 80;
if ($width > $wmax) {
$height = ($wmax/$width)*$height;
$width = $wmax;
}elseif( $height > $hmax) {
$width = ($hmax/$height)*$width;
$height = $hmax;
}
$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,$quality);
Imagedestroy($imgNew);
}
on line 261 in db_input.php (dont know if it has changed since last update)
if someone thinks to use this feature, here is the correct code:
if (eregi ("\.jpe?g$", $uploaded_pic)) {
$imgOld = imagecreatefromjpeg($uploaded_pic);
$width = imagesx($imgOld);
$height = imagesy($imgOld);
$wmax = 640;
$hmax = 480;
$quality = 80;
if ($width > $wmax or $height > $hmax) {
if( $width > $height ){
$height = ($wmax/$width)*$height;
$width = $wmax;
}else{
$width = ($hmax/$height)*$width;
$height = $hmax;
}
}
$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,$quality);
Imagedestroy($imgNew);
}
See:
http://forum.coppermine-gallery.net/index.php?topic=464.0
http://www.imagemagick.org/www/mogrify.html