forum.coppermine-gallery.net

No Support => Feature requests => Topic started by: diogo86 on May 17, 2004, 12:12:41 am

Title: no full size only normal (intermediate)
Post by: diogo86 on May 17, 2004, 12:12:41 am
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!
Title: Re: no full size only normal (intermediate)
Post by: diogo86 on May 17, 2004, 12:33:08 am
not tested yet but i guess it has solved my problem:

http://forum.coppermine-gallery.net/index.php?topic=464.0

just a improvement:

Code: [Select]
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)
Title: Re: no full size only normal (intermediate)
Post by: diogo86 on May 17, 2004, 02:02:04 am
if someone thinks to use this feature, here is the correct code:

Code: [Select]
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);
}
Title: Re: no full size only normal (intermediate)
Post by: spaceman on July 02, 2004, 06:06:42 pm
See:

http://forum.coppermine-gallery.net/index.php?topic=464.0

http://www.imagemagick.org/www/mogrify.html