coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: SmileyFace on May 02, 2011, 04:11:57 PM

Title: Thumbnails settings?
Post by: SmileyFace on May 02, 2011, 04:11:57 PM
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?
Title: Re: Thumbnails settings?
Post by: Αndré on May 03, 2011, 11:48:47 AM
Please post a link to your gallery.
Title: Re: Thumbnails settings?
Post by: SmileyFace on May 03, 2011, 12:28:09 PM
No need, I managed to do what I wanted. :)
Title: Re: Thumbnails settings?
Post by: Αndré on May 03, 2011, 12:34:11 PM
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.
Title: Re: Thumbnails settings?
Post by: SmileyFace on May 03, 2011, 03:53:06 PM
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?
Title: Re: Thumbnails settings?
Post by: Αndré on May 03, 2011, 04:49:45 PM
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;
Title: Re: Thumbnails settings?
Post by: SmileyFace on May 16, 2011, 10:14:47 PM
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. :/
Title: Re: Thumbnails settings?
Post by: Αndré on May 17, 2011, 09:38:01 AM
It's in the official package you can download here (http://sourceforge.net/projects/coppermine/files/). Alternatively you can download the cpg1.5.12 version from our svn repository (http://coppermine.svn.sourceforge.net/viewvc/coppermine/tags/cpg1.5.12/include/picmgmt.inc.php?revision=8156&view=markup).
Title: Re: Thumbnails settings?
Post by: SmileyFace on May 19, 2011, 04:49:33 PM
Thanks, it worked. And big thank you for everything else.