0
votes

I'm using imagemagick to resize photographs in my app, but I'm having trouble getting it to work as I need it to.

Can someone please help me come up with the right combination of option configurations to meet the following requirements:

  • Images should be resized to 320x213:
    • Set the height to exactly 213px
    • If the image is smaller than 320x213, enlarge it
    • If the image is larger than 320x213, make it smaller
    • Preserve the aspect ratio of the image
  • If the resized image is narrower than 320px:
    • center the image horizontally
    • add a background colour to the back of the image
    • preserve the aspect ratio of the image
  • If the resized image is wider than 320px:
    • trim the additional pixels evenly from both sides
1
What is your ImageMagick version and platform? You may have to script testing for the width.fmw42

1 Answers

3
votes

In ImageMagick, try

convert image -resize x213 -gravity center -background white -extent 320x213 result