やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

Raspbian+ImageMagickでJPGのExifを閲覧&削除する

 Logicool C200で撮影したJPGファイルが対象。

対象環境

前提

Exif情報

閲覧する

 C200にはExif情報が付与されない?

$ identify -verbose /tmp/work/img/20180912070626_F0.jpg
Image: /tmp/work/img/20180912070626_F0.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 640x480+0+0
  Resolution: 96x96
  Print size: 6.66667x5
  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: 307200
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 19.1263 (0.0750052)
      standard deviation: 9.28849 (0.0364254)
      kurtosis: 167.136
      skewness: 7.96758
    Green:
      min: 0 (0)
      max: 140 (0.54902)
      mean: 14.3607 (0.0563164)
      standard deviation: 3.52827 (0.0138364)
      kurtosis: 75.6936
      skewness: 3.67261
    Blue:
      min: 0 (0)
      max: 108 (0.423529)
      mean: 5.32058 (0.020865)
      standard deviation: 2.68146 (0.0105155)
      kurtosis: 99.0157
      skewness: 4.20816
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 12.9359 (0.0507289)
      standard deviation: 5.9418 (0.0233012)
      kurtosis: 389.521
      skewness: 12.5804
  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: 640x480+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: Undefined
  Properties:
    comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 255

    date:create: 2018-09-12T07:06:34+09:00
    date:modify: 2018-09-12T07:06:27+09:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: c8a76884c13ea0ea29ff3914bf57b3976efc8062044aeb480030ef409fecf538
  Artifacts:
    filename: /tmp/work/img/20180912070626_F0.jpg
    verbose: true
  Tainted: False
  Filesize: 15.2KB
  Number pixels: 307K
  Pixels per second: 10.24MB
  User time: 0.040u
  Elapsed time: 0:01.029
  Version: ImageMagick 6.8.9-9 Q16 arm 2018-06-26 http://www.imagemagick.org

削除する

$ convert -strip /tmp/before.jpg /tmp/after.jpg
ファイル サイズ
/tmp/before.jpg 14.8KB
/tmp/after.jpg 13.2KB

 削除後のExif閲覧すると以下。

$ identify -verbose /tmp/work/img/20180912070626_F0_convert.jpg
Image: /tmp/work/img/20180912070626_F0_convert.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 640x480+0+0
  Resolution: 96x96
  Print size: 6.66667x5
  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: 307200
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 19.1208 (0.0749836)
      standard deviation: 9.21754 (0.0361472)
      kurtosis: 161.701
      skewness: 7.77976
    Green:
      min: 0 (0)
      max: 133 (0.521569)
      mean: 14.3508 (0.0562778)
      standard deviation: 3.51319 (0.0137772)
      kurtosis: 70.038
      skewness: 3.57098
    Blue:
      min: 0 (0)
      max: 102 (0.4)
      mean: 5.34156 (0.0209473)
      standard deviation: 2.67788 (0.0105015)
      kurtosis: 102.004
      skewness: 4.3912
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 12.9377 (0.0507362)
      standard deviation: 5.90132 (0.0231424)
      kurtosis: 376.659
      skewness: 12.3229
  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: 640x480+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: Undefined
  Properties:
    date:create: 2018-09-12T08:19:01+09:00
    date:modify: 2018-09-12T08:19:01+09:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x2,1x1,1x1
    signature: e2c9f02fc547b6e2fa5f29d8937febdb34dc0a1db23cf3fd6c458651a4105276
  Artifacts:
    filename: /tmp/work/img/20180912070626_F0_convert.jpg
    verbose: true
  Tainted: False
  Filesize: 13.6KB
  Number pixels: 307K
  Pixels per second: 7.68MB
  User time: 0.040u
  Elapsed time: 0:01.039
  Version: ImageMagick 6.8.9-9 Q16 arm 2018-06-26 http://www.imagemagick.org

 どの情報が削除されたのかわかりにくい。Web Diff ツールを使って比較すると……

 削除前と比べて以下の情報が削除されていた。

comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 255

参考