确定os x上的bmp文件的位深度

use*_*066 1 macos command-line imagemagick image-processing bmp

如何在Mac OS X上确定bmp文件的位深度?特别是,我想检查bmp文件是否是真正的24位文件,或者是否将其保存为灰度(即8位)图像.我有一个黑白图像,我认为我被迫24位(使用convert -type TrueColor),但Imagemagick给出了相互矛盾的结果:

> identify -verbose hiBW24.bmp
...
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray

> identify -debug coder hiBW24.bmp   
...
Bits per pixel: 24
Run Code Online (Sandbox Code Playgroud)

许多其他命令行实用程序没有帮助,似乎:

> file hi.bmp 
hi.bmp: data

> exiv2 hiBW24.bmp 
File name       : hiBW24.bmp
File size       : 286338 Bytes
MIME type       : image/x-ms-bmp
Image size      : 200 x 477
hiBW24.bmp: No Exif data found in the file

> mediainfo -f hi.bmp
...[nothing useful]
Run Code Online (Sandbox Code Playgroud)

小智 5

如果你想要一个推荐行实用程序尝试sips(不要忘记阅读联机帮助页man sips).例:

*terminal input*
sips -g all /Users/hg/Pictures/2012/03/14/QRCodeA.bmp

*output is:*
/Users/hg/Pictures/2012/03/14/QRCodeA.bmp
pixelWidth: 150
pixelHeight: 143
typeIdentifier: com.microsoft.bmp
format: bmp
formatOptions: default
dpiWidth: 96.000
dpiHeight: 96.000
samplesPerPixel: 3
bitsPerSample: 8
hasAlpha: no
space: RGB
Run Code Online (Sandbox Code Playgroud)

我认为结果包含你所追求的价值观.

另一种方法是使用预览器打开图像preview.app并打开信息面板.

最具信息性的程序之一(但不易使用)是Phil Harvey的exiftool http://www.sno.phy.queensu.ca/~phil/exiftool/,它在MacOSX上也可以很好地用于很多文件格式,但可能是一个矫枉过正的目的.