安装 ImageMagick 包后会有一个命令
identify
使用该命令即可查看图片详情。
例如:
identify example.png
输出类似如下:
example.png PNG 1020×2754 1020×2754+0+0 8-bit sRGB 750KB 0.000u 0:00.000
如果想看更加详细的输出,则加上 -verbose 选项:
identify -verbose example.png
输出比较多:
Image: example.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 1020×2754+0+0
Resolution: 28.35×28.35
Print size: 35.9788×97.1429
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Pixels: 2809080
Red:
min: 0 (0)
max: 255 (1)
mean: 204.674 (0.802644)
standard deviation: 81.414 (0.319271)
kurtosis: 0.239677
skewness: -1.38498
Green:
min: 0 (0)
max: 255 (1)
mean: 207.794 (0.81488)
standard deviation: 79.2734 (0.310876)
kurtosis: 0.665358
skewness: -1.53063
Blue:
min: 0 (0)
max: 255 (1)
mean: 210.003 (0.823541)
standard deviation: 78.877 (0.309322)
kurtosis: 0.861659
skewness: -1.61903
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 155.618 (0.610266)
standard deviation: 69.163 (0.271228)
kurtosis: 6.56095
skewness: -2.02349
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1020×2754+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2015-03-16T16:31:31+08:00
date:modify: 2015-03-16T16:31:31+08:00
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 6
png:IHDR.color_type: 6 (RGBA)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 1020, 2754
png:pHYs: x_res=2835, y_res=2835, units=1
png:sRGB: intent=0 (Perceptual Intent)
signature: 6a369e9590b4ae45f4fde49cf23b5c60b1ab3e71a5f90e31e8bd88277f527c6b
Artifacts:
filename: example.png
verbose: true
Tainted: False
Filesize: 750KB
Number pixels: 2.809M
Pixels per second: 25.54MB
User time: 0.100u
Elapsed time: 0:01.109
Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-23 http://www.imagemagick.org
附上不同系统安装 ImageMagick 的命令:
yum install ImageMagick # CentOS apt-get install ImageMagick # Debian/Ubuntu brew install ImageMagick # Mac with brew