我试图在命令行中获取JPEG图像的高度和宽度。
我打字了GM标识IMG300.JPG并获得输出JPEG 3264x2448 0 0 DirectClass 8位1.8-bit 0.000U 0M:0.000002S
我在手册中查看了GM命令,它说我只能获得带有 - 密度选项的图像尺寸。
http://www.graphicsmagick.org/Indentify.html#Indent-opti
所以我尝试了GM标识 - 密度IMG300.jpg[选项需要争论]
gm标识img300.jpg-密度[没有这样的文件或目录]
Debian 9,最新的GraphicsMagick软件包是环境。
您可以得到这样的宽度:
gm identify -format %w image.png
256
和这样的高度:
gm identify -format %h image.png
80
如果要在变量中的高度:
h=$(gm identify -format %h image.png)
如果您要一次在变量中两个。
read w h < <(gm identify -format "%w %h" image.png )
echo $w, $h