Resize to a fixed geometry but maintain aspect ratio
Posted: 2008-11-25T11:24:27-07:00
Hello,
I need to convert an image from the command line to a fixed sized, but maintain the aspect ratio of the image content. This gets me close:
convert -resize 256x256 infile.jpg outfile.jpg
The problem being that I end up with one dimension that is less than 256 pixels. What I need is to fill in that space with black or transparent pixels above and below the image content to bring that dimension up to 256 pixels.
Any ideas on command line arg combinations to try?
I need to convert an image from the command line to a fixed sized, but maintain the aspect ratio of the image content. This gets me close:
convert -resize 256x256 infile.jpg outfile.jpg
The problem being that I end up with one dimension that is less than 256 pixels. What I need is to fill in that space with black or transparent pixels above and below the image content to bring that dimension up to 256 pixels.
Any ideas on command line arg combinations to try?