singapore: the smallest big galery
home » forum » General » automatic resize???

You are not logged in.

#1 2008-01-05 12:49:29

newbie
Member

automatic resize???

hello!

so i run singapore now for a couple of days and i really like this gallery. but it seems to be, that there is something not really working (at least maybe just on my webspace).

eg. wenn i upload a picture with a size of e.g 2000px, i can see the picture well in the thumbs, but when i click on the picture than i see it already in full size, without clicking on the link "full size".

so what i want to do is, to have actually "3 sizes" of the image. so first the thumb (which one is working) than when i click on the thumb, that i see the picture in 524x393px and the when i click on the "full size" link the 2000px.

so i hope that someone understand what i mean ;-)

kind regards and thanks in advance

Offline

 

#2 2011-08-18 15:41:32

focale31
Member

Re: automatic resize???

Hello,
fisrt, I do apologize for my poor english...

For automatic resizing, I put a few lines in admin.class.php :

Just after

// try to change file-permissions
@chmod($path, octdec($this->config->file_mode));

and before

}
    $img =& new sgImage($image, $this->gallery);


I have inserted these lines :

$source_pic = $path;
$destination_pic = $source_pic; // reduced image will replace original !
$max_width = 600;
$max_height = 600;
$src = imagecreatefromjpeg($source_pic); // 1. Copies source image
list($src_width,$src_height) = getimagesize($source_pic); // 2. Calculates image dimensions
$x_ratio = $max_width / $src_width;
$y_ratio = $max_height / $src_height;
if( ($src_width <= $max_width) && ($src_height <= $max_height) ){
    $tn_width = $src_width;
    $tn_height = $src_height;
    }elseif (($x_ratio * $src_height) < $max_height){ // 3. Resizes image & retains aspect ratio
    $tn_height = ceil($x_ratio * $src_height);
    $tn_width = $max_width;
    }else{
    $tn_width = ceil($y_ratio * $src_width);
    $tn_height = $max_height;
    }
    $tmp = imagecreatetruecolor($tn_width,$tn_height);
    imagecopyresampled($tmp,$src,0,0,0,0,$tn_width, $tn_height,$src_width,$src_height);
    imagejpeg($tmp,$destination_pic,95); // 4. Writes destination image & quality choice
    imagedestroy($tmp); // free memory


I hope you will enjoy !

http://www.focale31.com

Last edited by focale31 (2011-08-18 17:25:07)

Offline

 

#3 2011-08-21 17:59:37

DC
Administrator

Re: automatic resize???

Thanks for adding some useful information to this forum.

DC


To code or not to code that is the question?

Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php

Offline