coppermine-gallery.com/forum

Support => Older/other versions => cpg1.3.x Support => Topic started by: jpettit on November 15, 2004, 12:37:23 AM

Title: Thumbnail modifications?
Post by: jpettit on November 15, 2004, 12:37:23 AM
Hi there...
Wondering if it's possible to have Coppermine display the thumbnails at different size ratios than they do by default.  Looking to have square (1:1) thumbnails displayed.  Rather than squeeze a 4:3 image into 1:1 i would like it to just show a 1:1 ratio of a portion of the original.  Something along the lines of: http://www.lucky-33.com/photos/
Thanks.
Title: Re: Thumbnail modifications?
Post by: Joachim Müller on November 15, 2004, 07:04:59 AM
this has been asked before, although I'm not sure an answer/hack has been posted. Please search the board for "square thumbnail" or similar.

Joachim
Title: Re: Thumbnail modifications?
Post by: Casper on November 15, 2004, 12:32:42 PM
The only good example of this I can remember is this site lomoblog (http://lomoblog.com/index.php) by rbl.
He was asked but never posted the code to do it.
And he is still using version 1.2.0 which he has integrated with wordpress.
And he has not posted on here since January, so you are unlikely to get his help on this.
Title: Re: Thumbnail modifications?
Post by: owenb on November 12, 2005, 09:47:01 PM
I was sent a piece of code by a Coppermine user who has got square thumbnails to work exactly as you describe, using a hack that affects how ImageMagick processes images. It apparently goes in the pcmgmt.inc.php file.

However, I couldn't make it work, as I can't get ImageMagick working on my Mac, so I use GD2. I suspect I could make it work on the server I'm about to upload my Coppermine site to, but that's not much use for editing my site offline.

If anyone can suggest how this code might be adjusted to work with GD2, I'd be forever in your debt.

Owen

// height/width
    $srcWidth = $imginfo[0];
    $srcHeight = $imginfo[1];
    if ($thumb_use == 'ht') {
        $ratio = $srcHeight / $new_size;
    } elseif ($thumb_use == 'wd') {
        $ratio = $srcWidth / $new_size;
    } else {
        $ratio = max($srcWidth, $srcHeight) / $new_size;
    }
    $ratio = max($ratio, 1.0);
    $destWidth = (int)ceil($srcWidth / $ratio);
    $destHeight = (int)ceil($srcHeight / $ratio);
    $minSide = min($destHeight, $destWidth);
    $xOffset = (int)ceil($destWidth/2-$minSide/2);
    $yOffset = (int)ceil($destHeight/2-$minSide/2);

$cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -crop {$minSide}x{$minSide}+$xOffset+$yOffset ".str_replace("\\","/" ,$im_dest_file )." ".str_replace("\\","/" ,$im_dest_file );