thumbnail view, image-magic and auto-orient thumbnail view, image-magic and auto-orient
 

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 view, image-magic and auto-orient

Started by Fanch, December 21, 2012, 03:47:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fanch

Hello,

So to start, I install coppermine and  configured it to use imagemagic instead of gd.

I have add the imagmagick option : -auto-orient in the configuration panel.
So all my image resize and thumbnail creation are auto rotate as my camera add this informatin in exif data.
It is cool, and very easy to use :)

But I have an issue :
The thumbnail in album view are always using the same width and heigth for html attribute.
border="0" height="85" width="128"
So the vertical thumbnail are enlarge with the this value and this not very beautiful ...

The only way I found to resolve it, is to add in the css .image class of my theme (curve) the folowing code :
  width:auto;
which seem to overite the html attribute and work well.


You may remove from the html code, generated by php, one of the html attribute (width or heigth) or set one of them to auto by default.
I don't know how copermine work so, I can't say if it is a feature or a bug :)

Have a nice week-end ++





Αndré

Please post a link to your gallery and some directions where we can see the issue (without your fix).

Fanch

Sorry, but I can't give you access to my coppermine because it is on my own computer at home, and should not be exposed on internet.

I think it is because my original pics are not modified and so they keep there bad orientation.
So heigth and width are confused.

I have try some hack in php code : picmgmt.inc.php without success

$CURRENT_PIC_DATA['pwidth'] = $imagesize[0];
$CURRENT_PIC_DATA['pheight'] = $imagesize[1];

Wich are from   
$imagesize = cpg_getimagesize($image);

$image is the orginal photo, but thumbnail and intermediate picture may have different geometrie proportion when I use -auto-orient

I have try to call again  cpg_getimagesize() with $work_image after the resize but it don't work. (I am not very good in php so I don't know if modification in function affect parent object)

Maybe I should try to use the $normal and $thumb variable to get the good width and heigth but I am not sure of how(and where) to set this information in database using $CURRENT_PIC_DATA array




I haved another issue with the -auto-orient option in the same php file.

The vertical photo was resized  using the $ratio from original pics, which have inverse geometrie, so they were more small as my config is set

So I haved to calculed a percent to pass it to image magic :
[...]
} elseif ($thumb_use == 'wd') {
        // resize method width                                                                                                       
        $ratio = $srcWidth / $new_size;
        $percent = round(100 *  $new_size/$srcWidth);
    } elseif ($thumb_use == 'ht') {
   // resize method height                                                                                                       
        $ratio = $srcHeight / $new_size;
        $percent = round(100 *  $new_size/$srcHeight);
    } else { // resize method any                                                                                                     
        $ratio = max($srcWidth, $srcHeight) / $new_size;
        $percent = round(100 *  $new_size/max($srcWidth, $srcHeight));
    }
[...]
$destWidth = (int)($srcWidth / $ratio);
$destHeight = (int)($srcHeight / $ratio);
//        $resize_commands = "-geometry ".$destWidth."x".$destHeight;                                                         
$resize_commands = "-resize ".$percent."%";



So to finish, I think it is not an issue with coppermine.

I may have to rotate photo before upload them and every think should work well.

Idea or comment are welcomme ;)


Αndré

Quote from: Fanch on December 22, 2012, 03:21:50 AM
I may have to rotate photo before upload them and every think should work well.

That's probably the easiest solution. I'm sure there are tools that does that automatically, ImageMagick for example ;)