ImageMagick - 调整为最大宽度

Bre*_*ett 12 php image-manipulation imagemagick

我想将图像调整到最大width.所以我不关心图像的高度,但我只想将其调整到特定的宽度.

我确定我已经完成了这件事,之后我就不记得我现在是怎么做到的.

Bre*_*ett 32

似乎这是它的完成方式,注意宽度是第一个参数.

convert -resize '100' image.png
Run Code Online (Sandbox Code Playgroud)

对于其他任何想知道身高的人,那么你会这样做:

convert -resize 'x100' image.png
Run Code Online (Sandbox Code Playgroud)

资料来源:http://www.imagemagick.org/script/command-line-processing.php

编辑(2014年11月):请注意,在最新版本的ImageMagick中,根据KevinLabécot的评论,您不能再使用值的引号.

  • 请注意,如果您想要就地调整大量图像(而不是创建新文件),可以使用`mogrify`命令而不是`convert` (5认同)
  • 似乎不再允许使用引号设置大小(无效参数).我不得不删除引号,它完美地工作:`convert -resize 100 image.png` (3认同)

Sof*_*fox 8

你的问题含糊不清。您的标题要求将图像大小调整为最大宽度,但您似乎说要将图像大小调整为特定宽度。

如果您想将某些内容的最大宽度调整为 600 像素(即任何宽度小于 600 像素的图像将不受影响),请使用:

convert original_image.jpg -resize 600x\> result_image.jpg
Run Code Online (Sandbox Code Playgroud)

或者,直接修改原始图像:

mogrify  -resize 600x\> original_image.jpg
Run Code Online (Sandbox Code Playgroud)

如果您想要最大高度而不是最大宽度:

convert original_image.jpg -resize x600\> result_image.jpg
Run Code Online (Sandbox Code Playgroud)