CMYKのJPEG画像を探す(ImageMagick)
2011/04/01
develop
問題
RGBのJPEG画像とCMYKのJPEG画像が混ざってるらしいんだけど見つけられる?
回答例
ImageMagickの identify コマンドを使ってみる。
identifyコマンドは、画像のさまざまな情報、Exif情報などを抽出して出力してくれる。
# identify -verbose *.jpg | grep " Colorspace" Colorspace: CMYK Colorspace: CMYK Colorspace: CMYK Colorspace: CMYK Colorspace: RGB Colorspace: CMYK Colorspace: CMYK Colorspace: RGB Colorspace: RGB Colorspace: RGB Colorspace: RGB
バージョンが古い identifyコマンドのときは、 Type: が手がかりっぽい。
$ identify -verbose *.jpg | grep "Type:" Type: color separated これがCMYKらしい Type: color separated Type: color separated Type: color separated Type: true color これがRGBらしい Type: color separated Type: color separated Type: true color Type: true color Type: true color Type: true color
ちなみに、identifyコマンドの出力内容はこんな感じ。
$ identify -verbose test.jpg
Image: test.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: DirectClass
Geometry: 500x200
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 8-bits
Green: 8-bits
Blue: 8-bits
Channel statistics:
Red:
Min: 0 (0)
Max: 255 (1)
Mean: 197.665 (0.775156)
Standard deviation: 82.1549 (0.322176)
Green:
Min: 2 (0.00784314)
Max: 255 (1)
Mean: 197.466 (0.774377)
Standard deviation: 79.9252 (0.313432)
Blue:
Min: 0 (0)
Max: 255 (1)
Mean: 202.236 (0.793083)
Standard deviation: 74.4906 (0.29212)
Colors: 16632
Rendering intent: Undefined
Resolution: 72x72
Units: PixelsPerInch
Filesize: 30kb
Interlace: None
Background color: white
Border color: #DFDFDF
Matte color: grey74
Page geometry: 500x200+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 90
Orientation: Undefined
JPEG-Colorspace: 2
JPEG-Sampling-factors: 1x1,1x1,1x1
Signature: e550fb1ac55bffa5d805ffefc2a5d7de3d0aba1aa0bef54dd6f1223d3bc02285
Tainted: False
Version: ImageMagick 6.2.8 04/17/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html