使用ImageMagick调整尺寸,使其具有最大的宽度/高度 [英] Resize with ImageMagick with a maximal width / height

查看:258
本文介绍了使用ImageMagick调整尺寸,使其具有最大的宽度/高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令

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

调整图像大小,使其保持原始比例,最大宽度为800,最大高度为600像素.但是,如果图像在宽度和高度上都较小(例如300x200图像),它将被放大到800或600,我不希望这样.

resizes the image so that it keeps original ratio, with maximum width of 800, and maximum height of 600 pixels. But if the image is smaller both in width and height (e.g. a 300x200 image), it will be enlarged to reach 800 or 600, and I don't want this.

如何保持相同的调整大小(当宽度> 800或高度> 600时),但是使得图像的宽度和高度都小于 (例如300x200图像) ),会保持不变吗?

How to keep the same kind of resizing (when width > 800 or height > 600), but such that an image that is smaller both in width and height (e.g. a 300x200 image), will be untouched?

推荐答案

我认为您需要resize上的>标志.让我们创建一些图像(一个红色300x200,另一个蓝色1000x500):

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

现在将它们都转换为没有标志的800x600:

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

现在带有标志:

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

在Windows上可能需要插入符号(^),而不是反斜杠.

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

文档此处中说明了各种标志. .感谢@ user1133275的建议.

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

这篇关于使用ImageMagick调整尺寸,使其具有最大的宽度/高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆