This project is read-only.

Resize image with padding

Jul 25, 2013 at 12:48 AM
I need to be able to take a source image (JPG, PNG, GIF, BMP) and resize the image to a known height and width. The aspect ratio of the source image and the target sizes may not be the same, so I need to scale the original image so that it will fit in the target bounds, and then add padding to either the height or width, to center the image in the final target. The padding will ensure that the image is not skewed, when I view it in the target.
For example, I have an 800x600 image that I want to fit into 400x400. First I would resize the image to maintain the aspect ratio of 4:3 by resizing the original to 400x300. Then I want to pad the top and bottom of the image to have 100 blank pixels (white is fine). Ideally, this would all be one operation for efficiently; I only described two steps to make it simpler.

Is this sort of behavior possible in ImageTools using the existing capabilities? If not, what would you recommend extending/replacing to achieve this feature.

Nov 12, 2013 at 3:49 AM
I'm not sure whether ImageTools can do this or not, for your two steps, rasizing image to a know height and width and pad the top and bottom of the image to have a specific pixel, I would like to recommend this image processing tool with padding to you to have a test. I bought its license for its image barcode add-on, for image processing functions, you have a try with its free testing version.