Search code examples
imagemagick

How to resize an image to a certain height in ImageMagick 7?


I need to resize an image and the result image should have 300 pixels in height. The image must keep the aspect ratio of the original image.


Solution

  • To specify the height and keep the aspect ratio, use -resize x300

    magick in.jpg -resize x300 out.jpg
    

    For more ways to specify the target size, see https://imagemagick.org/Usage/resize/#resize