ImageMagick能否返回图片大小?
问题描述:
我从命令行使用ImageMagick调整图片大小:
I'm using ImageMagick from the command line to resize images:
convert -size 320x240 image.jpg
但是,我不知道如何确定最终图像的大小。由于这是一个成比例的图像缩放,新图片很有可能是100x240或320x90(不是320x240)。
However, I don't know how to determine the size of the final image. Since this is a proportional image scale, it's very possible that new image is 100x240 or 320x90 in size (not 320x240).
我可以调用'convert'图像并返回新的图像尺寸?例如,伪代码:
Can I call the 'convert' command to resize the image and return the new image dimensions? For example, pseudo code:
convert -size 320x240 -return_new_image_dimension image.jpg // returns the new resized image dimensions
答
您可以使用额外的
:
convert -size 320x240 image.jpg; identify -format "%[fx:w]x%[fx:h]" image.jpg