magick identify 程序描述了一个或多个图像文件的格式和特征。它还会报告图像是否不完整或损坏。返回的信息包括图像编号、文件名、图像的宽度和高度、图像是否为颜色映射、图像中的颜色数、图像中的字节数、图像的格式(JPEG、PNM 等),以及最后读取和处理图像所花费的秒数。使用详细选项可以获得更多属性。有关如何构建 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 提供以下输出
- 文件名[帧号] 图像格式 宽x高 页面宽x页面高+x偏移+y偏移 色彩空间 用户时间 经过时间
接下来,我们更详细地查看同一图像
$ 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 https://imagemagick.org.cn
请注意,图像签名是根据像素组件生成的,而不是图像元数据。
要获取 72 DPI 图像的英寸打印尺寸,请使用
$ magick identify -format "%[fx:w/72] by %[fx:h/72] inches" document.png 8.5 x 11 inches
必须在命令行上指定原始图像的深度和尺寸
$ 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
这是一个输出图像的最小或最大像素位置的特殊定义
magick identify -precision 5 -define identify:locate=maximum -define identify:limit=3 image.png
您可以在 ImageMagick 使用示例 中找到使用 magick identify 的其他示例。
选项摘要
magick identify 命令识别以下选项。单击某个选项以获取有关该选项工作原理的更多详细信息。
| 选项 | 描述 |
|---|---|
| -alpha | 开启、激活、关闭、停用、设置、不透明、复制、透明、提取、背景或塑造 alpha 通道 |
| -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 | 颜色、配置、委托、格式、魔法、模块、资源或类型 |
| -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 | 访问图像边界之外像素的方法 |