phenomenonex2 / slideshow

Automatically exported from code.google.com/p/slideshow
0 stars 0 forks source link

Per-image centering options... #124

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
A suggested enhancement for the 'center' option...
Current settings are resize:true and center:true
Since the center option affects all images, you can get some awkward
cropping, depending on where the focus of the photo is.

If there were a data parameter for centering, similar to how captions are
defined, users could easily control which images are centered. If the user
provides this parameter, it would override the global option:

'1.jpg': {
    caption: 'Keylin', 
    href: 'keylin.html',
    center: false
  },

Use case: A set of portraits of people may include some headshots and some
'full-length' photos. The headshots look fine centered & cropped, but if a
full-length photo is centered the head gets cropped off. A per-image
setting could override the current center setting as needed.

I've already made my own crude modification to support this, but I'm
certain there could be a more elegant approach, perhaps even to specify
_where_ to center:
   center: false  //off
   center: middle  //vertical & horizontal centering (current behavior)
   center: top-center  //only horiz. centering
   center: bottom-right  //focus on bottom-right corner
   etc...

Original issue reported on code.google.com by Andrew.M...@gmail.com on 4 Dec 2009 at 8:10

GoogleCodeExporter commented 8 years ago

Original comment by aeron.gl...@gmail.com on 7 May 2010 at 11:14

GoogleCodeExporter commented 8 years ago

Original comment by aeron.gl...@gmail.com on 7 May 2010 at 11:14

GoogleCodeExporter commented 8 years ago
I made another _resize type and added it the _resize function to deal with 
portrait sized photos.
if (this.options.resize == 'custom') {
    if( w > h ) {
        var percent = this.width / w;
    }
    else {
        var percent = this.height / h;
    }
}
img.set('styles', {'height': Math.ceil(h * percent), 'width': Math.ceil(w * 
percent)});

Original comment by ben...@gmail.com on 18 May 2011 at 6:15