Search code examples
imagemagick

How do I resize an image so that the longest size is shorter or equal to an amount?


The following resizes JPEG files so that the width becomes at most 1000px:

mogrify -resize "1000>" *.jpg

How do I resize the JPEGs so that the longer side is less than 1000px?


See also: documentation on -resize argument format.


Solution

  • It should keep the aspect ratio / image proportions when using a geometry string with ">", so you can just do:

    mogrify -resize "1000x1000>" *.jpg
    

    So you're explicitly limiting the image to being, at most, 1000x1000 pixels, and keeping the current aspect ratio of the image.