Resize with ImageMagick with a maximal width / height

前端 未结 1 862
无人共我
无人共我 2021-02-19 02:46

The command

imageconvert.exe in.jpg -resize 800x600 out.jpg

resizes the image so that it keeps original ratio, with maximum width of 800, and

相关标签:
1条回答
  • 2021-02-19 03:12

    I think you need the > flag on the resize. Let's create some images (one red 300x200, another blue 1000x500):

    convert -size 300x200 xc:red   small.png
    convert -size 1000x500 xc:blue large.png
    

    Now convert them both to 800x600 with no flags:

    convert small.png -resize 800x600 a.png   # 800x533
    convert large.png -resize 800x600 b.png   # 800x400
    

    Now with flags:

    convert small.png -resize 800x600\> a.png # 300x200
    convert large.png -resize 800x600\> b.png # 800x400
    

    You may need a caret (^) rather than a backslash on Windows.

    The various flags are explained in the documentation here. Thanks to @user1133275 for the suggestion.

    0 讨论(0)
提交回复
热议问题