Resize image to bounding box and maintain aspect
Posted: Fri Feb 10, 2012 12:18 am
Perhaps I am just not reading the docs enough, but I am having trouble finding a solution to my resize problem. I have to resize a set of images to fit within a specific set of dimensions (a bounding box). I don't which axis might need to be adjusted ahead of time (height or width). So, for example, if the bounding area is 100x100 and I give it an image of 200x100, then the resized result would be 100x50. The straight Resize method doesn't maintain aspect ratios. The ResizeHeightRatio and ResizeWidthRatio methods assume you know ahead of time which axis needs adjustment. The CreateThumbnailHQ method seems to be a bit closer, but then appears to fill the background with a color instead of just keeping the aspect ratio.
Is there a single method I can use to solve this problem? Or do I need to do the math myself ahead of time and then just call Resize?
Thanks,
Bryan
Is there a single method I can use to solve this problem? Or do I need to do the math myself ahead of time and then just call Resize?
Thanks,
Bryan