identify
使用示例 • 选项一览
magick identify 程序描述一个或多个图像文件的格式和特性。它还会报告图像是否不完整或已损坏。返回的信息包括图像编号、文件名、图像的宽度和高度、图像是否为颜色映射图像、图像中的颜色数、图像的字节数、图像的格式(JPEG、PNM 等),最后是读取和处理该图像所花费的秒数。使用 verbose 选项可获得更多属性。关于如何组织 magick identify 命令的建议,请参阅命令行处理,或参阅下文的命令使用示例。
使用示例
我们在此列出几个 magick identify 命令的示例,以说明其实用性和易用性。首先,让我们识别一张 JPEG 格式的图像:
$ magick identify rose.jpg
rose.jpg JPEG 70x46 70x46+0+0 8-bit sRGB 2.36KB 0.000u 0:00.000
默认情况下,magick identify 提供以下输出:
Filename[frame #] image-format widthxheight page-widthxpage-height+x-offset+y-offset colorspace user-time elapsed-time
接下来,我们更详细地查看同一张图像:
$ magick identify -verbose rose.jpg
Image: rose.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 70x46+0+0
Units: Undefined
Type: TrueColor
Endianness: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 3220
Red:
min: 31 (0.121569)
max: 255 (1)
mean: 145.557 (0.570814)
standard deviation: 69.1933 (0.271346)
kurtosis: -1.38945
skewness: 0.138955
entropy: 0.970683
Green:
min: 27 (0.105882)
max: 255 (1)
mean: 89.246 (0.349984)
standard deviation: 52.4608 (0.205729)
kurtosis: 2.60139
skewness: 1.80708
entropy: 0.869711
Blue:
min: 21 (0.0823529)
max: 255 (1)
mean: 80.4196 (0.315371)
standard deviation: 54.9377 (0.215442)
kurtosis: 2.93417
skewness: 1.95544
entropy: 0.853176
Image statistics:
Overall:
min: 21 (0.0823529)
max: 255 (1)
mean: 105.074 (0.412056)
standard deviation: 58.8639 (0.230839)
kurtosis: 1.37788
skewness: 1.48073
entropy: 0.897856
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33,0.03)
green primary: (0.3,0.6,0.1)
blue primary: (0.15,0.06,0.79)
white point: (0.3127,0.329,0.3583)
Alpha color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 70x46+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 92
Orientation: Undefined
Properties:
jpeg:colorspace: 2
jpeg:sampling-factor: 1x1,1x1,1x1
signature: aea65c9b557d779d142f26d04abe7008bab50f1e9647faae20afdcc6c15140d5
Artifacts:
verbose: true
Tainted: False
Filesize: 2.65KB
Number pixels: 3.22K
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 7.0.4-8 Q16 x86_64 http://imagemagick.org
请注意,图像签名是从像素分量生成的,而非图像元数据。
要以英寸为单位获取图像在 72 DPI 下的打印尺寸,请使用:
$ magick identify -format "%[fx:w/72] by %[fx:h/72] inches" document.png
8.5 x 11 inches
原始(raw)图像的位深度和尺寸必须在命令行中指定:
$ magick identify -depth 8 -size 640x480 image.raw
image.raw RGB 640x480 sRGB 9kb 0.000u 0:01
下面我们显示图像的纹理特征、矩、感知哈希以及图像中唯一颜色的数量:
$ magick identify -verbose -features 1 -moments -unique image.png
要显示图像的凸包和最小外接矩形属性,请使用:
magick identify -define identify:convex-hull=true image.png
这里有一个特殊的 define,用于输出图像中最小或最大像素的位置:
magick identify -precision 5 -define identify:locate=maximum -define identify:limit=3 image.png
你可以在 Examples of ImageMagick Usage 中找到更多使用 magick identify 的示例。
选项一览
magick identify 命令可识别以下选项。点击某个选项可获取有关其工作方式的更多详情。
| 选项 | 说明 |
|---|---|
| -alpha | 对 alpha 通道指定 on, activate, off, deactivate, set, opaque, copy, transparent, extract, background, shape |
| -antialias | 去除像素混叠 |
| -authenticate value | 用此密码解密图像 |
| -auto-orient | 自动调整图像方向 |
| -channel type | 将选项应用于选定的图像通道 |
| -clip | 沿 8BIM 配置文件中的第一条路径进行裁剪 |
| -clip-mask filename | 将裁剪蒙版与图像关联 |
| -clip-path id | 沿 8BIM 配置文件中的命名路径进行裁剪 |
| -colorspace type | 设置图像色彩空间 |
| -crop geometry | 裁剪图像 |
| -debug events | 显示大量调试信息 |
| -define format:option | 定义一个或多个图像格式选项 |
| -density geometry | 图像的水平和垂直密度 |
| -depth value | 图像位深度 |
| -endian type | 图像的字节序(MSB 或 LSB) |
| -extract geometry | 从图像中提取区域 |
| -features distance | 分析图像特征(如对比度、相关性等) |
| -format string | 格式化输出图像特性 |
| -gamma value | 伽马校正的级别 |
| -grayscale method | 将图像转换为灰度 |
| -help | 打印程序选项 |
| -interlace type | 图像隔行扫描方式的类型 |
| -interpolate method | 像素颜色插值方法 |
| -limit type value | 像素缓存资源上限 |
| -list type | Color, Configure, Delegate, Format, Magic, Module, Resource, Type 之一 |
| -log format | 调试信息的格式 |
| -mask filename | 将蒙版与图像关联 |
| -moments | 显示图像矩和感知哈希 |
| -monitor | 监视进度 |
| -negate | 将每个像素替换为其补色 |
| -ping | 默认情况下,仅读取必需的图像元数据以高效判定特定的图像特性。要准确识别所有图像元数据和像素特性,请使用 +ping。 |
| -precision value | 设置打印的最大有效位数 |
| -quiet | 抑制所有警告消息 |
| -regard-warnings | 重视警告消息 |
| -respect-parentheses | 设置在括号边界之前保持有效 |
| -sampling-factor geometry | 水平和垂直采样系数 |
| -set attribute value | 设置图像属性 |
| -size geometry | 图像的宽度和高度 |
| -strip | 从图像中剥离所有配置文件和注释 |
| -unique | 显示图像中唯一颜色的数量 |
| -units type | 图像分辨率的单位 |
| -verbose | 打印图像的详细信息 |
| -version | 打印版本信息 |
| -virtual-pixel method | 访问图像边界外像素的方法 |