Thumbnail modifications? Thumbnail modifications?
 

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

Thumbnail modifications?

Started by jpettit, November 15, 2004, 12:37:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jpettit

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.

Joachim Müller

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

Casper

#2
The only good example of this I can remember is this site lomoblog 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.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

owenb

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 );