# Scaling a centered image to longest dimension

**URL:** <https://forum.kirupa.com/t/scaling-a-centered-image-to-longest-dimension/257242>\
**Category:** Uncategorized\
**Created:** [April 11, 2008, 4:29pm UTC](https://forum.kirupa.com/t/scaling-a-centered-image-to-longest-dimension/257242 "2008-04-11T16:29:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatbat](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@Fatbat](https://forum.kirupa.com/u/Fatbat)\
**Post date:** [April 11, 2008, 4:29pm UTC](https://forum.kirupa.com/t/scaling-a-centered-image-to-longest-dimension/257242/1 "2008-04-11T16:29:45Z")

</div>

OK, I am attempting to create an image gallery like this one…

[http://www.manhattanstonetile.com/](http://www.manhattanstonetile.com/)

Basically I would like the loaded jpg to center and scale to it’s longest side within the stage. So a portrait shot will stretch 100% from top to bottom but might have bars on either side. A landscape shot might letterbox if it is short enough. However, if the landscape shot is too tall, the top and bottom would bleed off the screen.

Make sense?
