简介
图片元数据,包括格式、宽、高、分辨率、颜色通道、透明通道、质量指数(压缩率)、位深度、像素数等,可以通过工具ImageMagic来读取,ImageMagic是个很强大的图片处理工具,包括创建图片、编辑图片、转换图片、压缩图片等等,而且支持几乎所有的图片格式。此处介绍读取元数据的方法。
安装
下载地址:https://imagemagick.org/script/download.php
按指定系统下载相应的安装文件安装即可
读取元数据方法
命令:identity -verbose img.png
在终端输入上述命令,即可查看img.png相关的元数据,终端输出如下
PS D:\> identify -verbose .\img.png
Image: .\img.pngFormat: PNG (Portable Network Graphics)Mime type: image/pngClass: DirectClassGeometry: 1920x1080+0+0Units: UndefinedType: TrueColorAlphaEndianess: UndefinedColorspace: sRGBDepth: 8-bitChannel depth:Red: 8-bitGreen: 8-bitBlue: 8-bitAlpha: 1-bitChannel statistics:Pixels: 2073600Red:min: 0 (0)max: 99 (0.388235)mean: 23.3212 (0.0914559)standard deviation: 10.3488 (0.0405833)kurtosis: 8.774skewness: 2.61234entropy: 0.661315Green:min: 43 (0.168627)max: 124 (0.486275)mean: 73.8182 (0.289483)standard deviation: 14.5364 (0.0570055)kurtosis: -1.21146skewness: -0.00118234entropy: 0.872026Blue:min: 64 (0.25098)max: 154 (0.603922)mean: 110.348 (0.432739)standard deviation: 15.3797 (0.0603125)kurtosis: -0.935226skewness: -0.196375entropy: 0.871399Alpha:min: 255 (1)max: 255 (1)mean: 255 (1)standard deviation: 0 (0)kurtosis: 0skewness: 0entropy: 0.660578Image statistics:Overall:min: 0 (0)max: 255 (1)mean: 115.622 (0.45342)standard deviation: 11.7786 (0.0461904)kurtosis: 5972.14skewness: 273.901entropy: 0.76633Rendering intent: PerceptualGamma: 0.45455Chromaticity:red primary: (0.64,0.33)green primary: (0.3,0.6)blue primary: (0.15,0.06)white point: (0.3127,0.329)Alpha color: grey74Background color: whiteBorder color: srgb(223,223,223)Transparent color: noneInterlace: PNGIntensity: UndefinedCompose: OverPage geometry: 1920x1080+0+0Dispose: UndefinedIterations: 0Compression: ZipOrientation: UndefinedProperties:date:create: 2019-08-27T18:44:05+08:00date:modify: 2019-08-27T14:31:12+08:00png:cHRM: chunk was found (see Chromaticity, above)png:gAMA: gamma=0.45455 (See Gamma, above)png:IHDR.bit-depth-orig: 8png:IHDR.bit_depth: 8png:IHDR.color-type-orig: 6png:IHDR.color_type: 6 (RGBA)png:IHDR.interlace_method: 1 (Adam7 method)png:IHDR.width,height: 1920, 1080png:sRGB: intent=0 (Perceptual Intent)signature: cf4198447e67df2147c2db732d9c998423b0b5c586f1b2fc382ce01f560de357Artifacts:verbose: trueTainted: FalseFilesize: 433KBNumber pixels: 2.074MPixels per second: 15.59MBUser time: 0.094uElapsed time: 0:01.133Version: ImageMagick 7.0.1-6 Q16 x64 2016-05-21 http://www.imagemagick.org
从输出可以看到,读取出了很全面的信息,包括图片的格式、mime类型、颜色空间、位深度、颜色通道信息、透明通道信息、压缩方式、质量指数(压缩率)、像素数等等