Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: no full size only normal (intermediate)  (Read 5046 times)

0 Members and 1 Guest are viewing this topic.

diogo86

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
no full size only normal (intermediate)
« 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!
Logged

diogo86

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: no full size only normal (intermediate)
« Reply #1 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)
Logged

diogo86

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: no full size only normal (intermediate)
« Reply #2 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);
}
Logged

spaceman

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 16
    • Itomic Business Website Solutions
Logged
www.itomic.com - perth business website solutions
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 19 queries.