Thumbnails settings? Thumbnails settings?
 

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]

Main Menu

Thumbnails settings?

Started by SmileyFace, May 02, 2011, 04:11:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SmileyFace

Thumbnails gave me some hard time, so I decided to ask for help.
Basically I want my thumbnails to be all the same height and width, so I used "Exact", however, it stretches and gather images depending on their width.
It's annoying, I want something like this http://selenagomezgallery.com/thumbnails.php?album=119
Help please?

Αndré

Please post a link to your gallery.

SmileyFace

No need, I managed to do what I wanted. :)

Αndré

Quote from: Joachim Müller on September 28, 2008, 12:46:26 PM
Resolve your threads
If you have found an answer to your question, resolve your thread. Don't just post "I have found the answer", but tell others what you actually did to solve your issues. Posting a link to the page where you found the answer might help. Describing what you did might help as well. Finally, you can tag your answer as "solved" by clicking on the little image in your initial posting on your thread.

SmileyFace

Oh, I'm sorry.
I just logged in tomorrow and it looked fine, however it shows center of the image as thumbnail, is there any way I can make thumbnails show top of the image?

Αndré

Quote from: SmileyFace on May 03, 2011, 03:53:06 PM
is there any way I can make thumbnails show top of the image?
You have to adjust the following code in include/picmgmt.inc.php:
            switch ($CONFIG['thumb_method']) {
                //cropping parameters for ImageMagick
                case "im" :
                    $resize_commands="";
                    if ($srcWidth/$srcHeight > $thb_width/$thb_height) {
                        $resize_commands .= "-resize x".$thb_height;
                        $resized_w = ($thb_height/$srcHeight) * $srcWidth;
                        $resize_commands .= " -crop ".$thb_width."x".$thb_height."+".round(($resized_w - $thb_width)/2)."+0";
                    } else {
                        $resize_commands .= "-resize ".$thb_width;
                        $resized_h = ($thb_width/$srcWidth) * $srcHeight;
                        $resize_commands .= " -crop ".$thb_width."x".$thb_height."+0+".round(($resized_h - $thb_height)/2);
                    }
                    break;

                // cropping parameters for GD2
                default :
                    if($srcHeight < $srcWidth) {
                        $ratio = (double)($srcHeight / $thb_height);
                        $cpyWidth = round($thb_width * $ratio);
                        if ($cpyWidth > $srcWidth) {
                            $ratio = (double)($srcWidth / $thb_width);
                            $cpyWidth = $srcWidth;
                            $cpyHeight = round($thb_height * $ratio);
                            $xOffset = 0;
                            $yOffset = round(($srcHeight - $cpyHeight) / 2);
                        } else {
                            $cpyHeight = $srcHeight;
                            $xOffset = round(($srcWidth - $cpyWidth) / 2);
                            $yOffset = 0;
                        }

                    } else {
                        $ratio = (double)($srcWidth / $thb_width);
                        $cpyHeight = round($thb_height * $ratio);
                        if ($cpyHeight > $srcHeight) {
                            $ratio = (double)($srcHeight / $thb_height);
                            $cpyHeight = $srcHeight;
                            $cpyWidth = round($thb_width * $ratio);
                            $xOffset = round(($srcWidth - $cpyWidth) / 2);
                            $yOffset = 0;
                        } else {
                            $cpyWidth = $srcWidth;
                            $xOffset = 0;
                            $yOffset = round(($srcHeight - $cpyHeight) / 2);
                        }
                    }

                    $destWidth = $thb_width;
                    $destHeight = $thb_height;
                    $srcWidth = $cpyWidth;
                    $srcHeight = $cpyHeight;
                    break;
            }


If you're using GD2 to create your thumbnails, you'll have to change the second occurrence of
$yOffset = round(($srcHeight - $cpyHeight) / 2);
to
$yOffset = 0;

SmileyFace

I've messed something up, is there any way to get picmgmt.inc.php any how? I deleted something from it and now it doesn't work. :/

Αndré

It's in the official package you can download here. Alternatively you can download the cpg1.5.12 version from our svn repository.

SmileyFace

Thanks, it worked. And big thank you for everything else.