それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

写真の情報(撮影日・カメラなど)を取り出すコマンド

identify コマンドか、exiftool コマンドを使う

identify -verbose /Users/takuya/Desktop/CA3G0323.JPG
exiftool  /Users/takuya/Desktop/CA3G0323.JPG

写真の情報を取り出すにはexiftools が便利です

takuya@rena:~/Desktop$ exiftool /Users/takuya/Desktop/CA3G0323.JPG
ExifTool Version Number         : 9.76
File Name                       : CA3G0323.JPG
Directory                       : /Users/takuya/Desktop
File Size                       : 2.1 MB
File Modification Date/Time     : 2011:11:03 16:39:42+09:00
File Access Date/Time           : 2015:02:23 00:39:35+09:00
File Inode Change Date/Time     : 2015:02:23 00:39:34+09:00
File Permissions                : rw-------
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Image Description               : CA3G0323
Make                            : KDDI-CA
Camera Model Name               : CA004
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/25
Exif Version                    : 0220
Date/Time Original              : 2011:11:03 16:39:42
Create Date                     : 2011:11:03 16:39:42
Components Configuration        : Y, Cb, Cr, -
Exposure Compensation           : 0
Flash                           : No flash function
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 3264
Exif Image Height               : 1960
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Custom Rendered                 : Normal
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 1.133333333
Scene Capture Type              : Standard
Gain Control                    : None
Saturation                      : Normal
Subject Distance Range          : Unknown
PrintIM Version                 : 0300
Compression                     : JPEG (old-style)
Thumbnail Offset                : 32112
Thumbnail Length                : 7068
Image Width                     : 3264
Image Height                    : 1960
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
Image Size                      : 3264x1960
Shutter Speed                   : 1/25
Thumbnail Image                 : (Binary data 7068 bytes, use -b option to extract)

identify コマンドでも取り出せる

identify コマンドでもチャント取り出せるんだけど、こっちはもっと情報が多くて反って混乱しそうな感じはある。

Image: /Users/takuya/Desktop/CA3G0323.JPG
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 3264x1960+0+0
  Resolution: 72x72
  Print size: 45.3333x27.2222
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 6397440
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 122.992 (0.482321)
      standard deviation: 78.4245 (0.307547)
      kurtosis: -1.16977
      skewness: -0.175524
      entropy: 0.939368
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 133.43 (0.523254)
      standard deviation: 81.6469 (0.320184)
      kurtosis: -1.27911
      skewness: -0.285099
      entropy: 0.956139
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 130.948 (0.51352)
      standard deviation: 88.2209 (0.345964)
      kurtosis: -1.36886
      skewness: -0.176941
      entropy: 0.929486
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 129.123 (0.506365)
      standard deviation: 82.8644 (0.324959)
      kurtosis: -1.26568
      skewness: -0.202622
      entropy: 0.941664
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 3264x1960+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: TopLeft
  Properties:
    date:create: 2015-02-23T00:39:34+09:00
    date:modify: 2011-11-03T16:39:42+09:00
    exif:ColorSpace: 1
    exif:ComponentsConfiguration: 1, 2, 3, 0
    exif:CustomRendered: 0
    exif:DateTimeDigitized: 2011:11:03 16:39:42
    exif:DateTimeOriginal: 2011:11:03 16:39:42
    exif:DigitalZoomRatio: 3264/2880
    exif:ExifImageLength: 1960
    exif:ExifImageWidth: 3264
    exif:ExifOffset: 306
    exif:ExifVersion: 48, 50, 50, 48
    exif:ExposureBiasValue: 0/10
    exif:ExposureMode: 0
    exif:ExposureTime: 800/20000
    exif:Flash: 32
    exif:FlashPixVersion: 48, 49, 48, 48
    exif:GainControl: 0
    exif:ImageDescription: CA3G0323
    exif:InteroperabilityOffset: 31952
    exif:Make: KDDI-CA
    exif:MakerNote: 0, 0, 0, 43, 0, 0, 0, 7, 0, 0, 108, 27, 0, 0, 2, 8, 0, 1, 0, 7, 0, 0, 0, 4, 0, 0, 0, 0, 0, 2, 0, 7, 0, 0, 0, 4, 0, 0, 0, 1, 0, 3, 0, 7, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 0, 7, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 7, 0, 0, 0, 4, 0, 0, 3, 32, 0, 6, 0, 7, 0, 0, 0, 4, 0, 0, 78, 32, 0, 7, 0, 7, 0, 0, 0, 4, 0, 0, 0, 201, 0, 8, 0, 7, 0, 0, 0, 4, 0, 0, 0, 0, 0, 9, 0, 7, 0, 0, 0, 4, 0, 0, 0, 117, 0, 10, 0, 7, 0, 0, 0, 4, 0, 0, 0, 153, 0, 11, 0, 7, 0, 0, 0, 4, 0, 0, 1, 252, 0, 12, 0, 7, 0, 0, 0, 4, 0, 0, 1, 0, 0, 13, 0, 7, 0, 0, 0, 4, 0, 0, 1, 168, 0, 14, 0, 7, 0, 0, 0, 4, 0, 0, 19, 130, 0, 15, 0, 7, 0, 0, 0, 4, 0, 0, 0, 32, 0, 16, 0, 7, 0, 0, 0, 4, 0, 0, 0, 1, 0, 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, 6, 9, 13, 11, 13, 13, 13, 11, 12, 12, 14, 16, 20, 17, 14, 15, 19, 15, 12, 12, 18, 24, 18, 19, 21, 22, 23, 23, 23, 14, 17, 25, 27, 25, 22, 26, 20, 22, 23, 22, 1, 4, 4, 4, 5, 5, 5, 10, 6, 6, 10, 22, 15, 12, 15, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 255, 192, 0, 17, 8, 0, 240, 1, 144, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 1, 162, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 218, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, 249, 30, 199, 226, 206, 169, 109, 225, 1
    exif:Model: CA004
    exif:Orientation: 1
    exif:PrintImageMatching: 80, 114, 105, 110, 116, 73, 77, 0, 48, 51, 48, 48, 0, 0, 0, 10, 0, 1, 0, 18, 0, 18, 0, 2, 1, 0, 0, 0, 0, 14, 0, 0, 0, 76, 1, 1, 255, 0, 0, 0, 1, 2, 129, 0, 0, 0, 1, 3, 129, 0, 0, 0, 1, 4, 128, 0, 0, 0, 1, 5, 130, 0, 0, 0, 1, 6, 130, 0, 0, 0, 1, 7, 130, 130, 130, 0, 241, 0, 246, 0, 246, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0
    exif:ResolutionUnit: 2
    exif:Saturation: 0
    exif:SceneCaptureType: 0
    exif:SubjectDistanceRange: 0
    exif:thumbnail:Compression: 6
    exif:thumbnail:InteroperabilityIndex: R98
    exif:thumbnail:InteroperabilityVersion: 48, 49, 48, 48
    exif:thumbnail:JPEGInterchangeFormat: 32100
    exif:thumbnail:JPEGInterchangeFormatLength: 7068
    exif:thumbnail:ResolutionUnit: 2
    exif:thumbnail:XResolution: 72/1
    exif:thumbnail:YResolution: 72/1
    exif:WhiteBalance: 0
    exif:XResolution: 72/1
    exif:YCbCrPositioning: 1
    exif:YResolution: 72/1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x1,1x1,1x1
    signature: b308b76ecd4fbc38fe031a0a5c26ba75d700a0b390fb2096aba4f9c087a63a58
  Profiles:
    Profile-exif: 39174 bytes
  Artifacts:
    filename: /Users/takuya/Desktop/CA3G0323.JPG
    verbose: true
  Tainted: False
  Filesize: 2.239MB
  Number pixels: 6.397M
  Pixels per second: 319.87GB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.0-3 Q32 x86_64 2015-02-07 http://www.imagemagick.org

プログラムから使うには各言語ようにバインディングを使う

ruby

gem install exifr # たぶんexif ruby の略

または

gem install rmagick # たぶん ruby imageMagick の略

php

php拡張機能としてdl するか php.ini で有効にする

php_exif

php の Imagick 関連は、別途インストールが必要なので、php 入門者にはちょっと敷居が高くてGDとかCairoがよく使われるんだけどね。。。画像処理の話はまた今度。

関連エントリ。

exiftool で任意のメタデータを取り出す - それマグで!

写真からGPS情報を抜き出して、地図にマッピングする - それマグで!

Exifを編集するにはexiftool が便利ですよね - それマグで!

identify 画像のexif情報を見る - それマグで!