I have some boxes that have the dimensions of 340 x 170
and users will be uploading images that need to be displayed into these boxes; however I'm not really sure how to go about resizing them so they don't lose aspect ratio and always fit in the box.
Requirements..
- Canvas should always be 340 x 170
- Image can't lose aspect ratio
- If the image has a greater width than height than it should be as wide as possible to 340px
- Ditto to the height
- Should always be able to see the whole image in the canvas
Normally you would just resize by the largest side, however this obviously won't work as then you will end up with a larger height than 170px if the height is close to the width.