1

使用exiv2,可以在终端输出图像信息。但是,它会输出几行信息:

exiv2 -ps ~/filelocation/filename.jpg

输出如下内容:

File name       : ~/filelocation/filename.jpg
File size       : 12345 Bytes
MIME type       : image/jpeg
Image size      : 800 x 600
~/filelocation/filename.jpg: No Exif data found in the file

如何命令终端仅输出图像大小数据?

我真正想要的是:

exiv2 -ps ~/filelocation/filename.jpg [some command here]

输出:

800 x 600
4

1 回答 1

2

尝试这个 -

exiv2 -ps ~/filelocation/filename.jpg |
  sed -n '/Image size/{ s/^.*: //; p; }'

sed-n禁止默认输出。

/pattern/逐行匹配。

{...}包装要对匹配的行执行的操作脚本。

s/^.*: //;剥离前导字符串。

p;打印值。

于 2018-06-26T17:30:33.077 回答