How to "smart resize" a displayed image to original aspect ratio
Posted
by Paul Sasik
on Stack Overflow
See other posts from Stack Overflow
or by Paul Sasik
Published on 2010-06-09T18:35:16Z
Indexed on
2010/06/09
18:42 UTC
Read the original article
Hit count: 368
I have an application in which end-users can size and position images in a designer. Since the spec calls for the image to be "stretched" to the containing control, the end user can end up with an awkwardly stretched image.
To help the user with image sizing I am thinking of implementing a smart resizer function which would allow the the user to easily fix the aspect ratio of the picture so that it no longer appears stretched.
The quick way to solve this is to actually provide two options: 1) scale from width 2) scale from height. The user chooses the method and the algorithm adjusts the size of the picture by using the original aspect ratio. For example: A picture is displayed as 200x200 on the designer but the original image is 1024x768 pixels. The user chooses "Smart Size from width" and the new size becomes ~200x150 since the original aspect ratio is ~1.333
That's OK, but how could I make the algorithm smarter and not bother the user by asking which dimension the recalculation should be based on?
© Stack Overflow or respective owner