jhead コマンドでExif 情報を削除する

デジカメのExifを削除するjhead コマンドについて。

jhead
http://www.sentex.net/~mwandel/jhead/


jheadコマンドは、Exif情報を削除するほか、ファイルの時刻を修正したりサムネイルを作成したりできる。

Exif 情報をまとめて削除するとファイル容量を減らす事ができるが、Exifの撮影日を削除するとデジカメプリントサービスなどで撮影日を写真にプリントできなくなる事も考慮しておく必要がある。

インストール

CentOS 6.x の場合、RPMforge から yum でインストール

# yum --enablerepo=rpmforge install jhead

使い方

使い方は

$ man jhead
$ jhead -h

で調べる。

書式

$ jhead [option] [files...]

複数ファイルを対象とする場合は、file1 file2 のようにスペースで区切って並べる。
*.jpg のようにワイルドカードの指定も可。

操作対象ファイルは、処理後に上書きされるため、必要に応じてバックアップを取ってから行う。

主なオプション

-h:ヘルプを表示
-v:詳細表示
-te fileA fileB:ファイルAのExif情報をファイルBのExif情報へコピーする
-de:Exifセクションを削除する
-du:Exifとコメント以外の画像セクションを削除する
-purejpg:画像を描画するため以外の不要な全データを削除する(-dc -de -du と同じ)
-cl string:引数の文字列をコメントとして挿入する
-ce:コメントを編集する(既定のエディタが起動する)
-dc:コメントを削除する

「-purejepg」と「e」を入れてしまうと書式エラーになる。「-purejpg」が正しい。

Argument '-purejpeg' not understood
Use jhead -h for list of arguments

例)オプションを付けずに実行すると、Exif情報を表示する

$ jhead test.jpg
File name    : test.jpg
File size    : 3462489 bytes
File date    : 2014:09:15 14:55:09
Camera make  : Canon
Camera model : Canon IXY 430F
Date/Time    : 2014:09:07 19:39:07
Resolution   : 4608 x 3456
Flash used   : Yes (auto, red eye reduction mode)
Focal length :  4.3mm  (35mm equivalent: 25mm)
CCD width    : 6.17mm
Exposure time: 0.017 s  (1/60)
Aperture     : f/2.7
Focus dist.  : 0.28m
ISO equiv.   : 500
Whitebalance : Auto
Metering Mode: matrix
GPS Latitude : ? ?
GPS Longitude: ? ?

例)test.jpg の Exif を test2.jpg へコピーする

$ jhead test2.jpg
File name    : test2.jpg
File size    : 2653 bytes
File date    : 2014:09:15 15:00:56
Resolution   : 64 x 64

$ jhead -te test.jpg test2.jpg
Modified: test2.jpg

確認(Exif情報のデータ分だけサイズが増える)
$ jhead test2.jpg
File name    : test2.jpg
File size    : 16017 bytes
File date    : 2014:09:15 15:00:56
Camera make  : Canon
Camera model : Canon IXY 430F
Date/Time    : 2014:09:07 19:39:07
Resolution   : 64 x 64
Flash used   : Yes (auto, red eye reduction mode)
Focal length :  4.3mm  (35mm equivalent: 25mm)
CCD width    : 6.17mm
Exposure time: 0.017 s  (1/60)
Aperture     : f/2.7
Focus dist.  : 0.28m
ISO equiv.   : 500
Whitebalance : Auto
Metering Mode: matrix
GPS Latitude : ? ?
GPS Longitude: ? ?

例)test.jpg の Exif を削除する

$ jhead -de test.jpg
Modified: test.jpg

確認
$ jhead test.jpg
File name    : test.jpg
File size    : 3444685 bytes
File date    : 2014:09:15 14:55:09
Resolution   : 4608 x 3456

例)test.jpg の Exifなど不要なデータを全て削除する

$ jhead -purejpg test.jpg
Modified: test.jpg

確認
$ jhead test.jpg
File name    : test.jpg
File size    : 3444587 bytes
File date    : 2014:09:15 14:55:09
Resolution   : 4608 x 3456

例)コメントを挿入する

$ jhead -cl this-is-comment test.jpg
Modified: test.jpg

確認
$ jhead test.jpg
File name    : test.jpg
File size    : 3444704 bytes
File date    : 2014:09:15 15:08:04
Resolution   : 4608 x 3456
Comment      : this-is-comment

例)コメントを編集する

$ jhead -ce test.jpg

既定のエディタが起動するので、編集して上書き保存する。

確認
$ jhead test.jpg
File name    : test.jpg
File size    : 3444706 bytes
File date    : 2014:09:15 15:08:04
Resolution   : 4608 x 3456
Comment      : this-is-comment!

例)コメントを削除する

$ jhead -dc test.jpg
Modified: test.jpg

確認
$ jhead test.jpg
File name    : test.jpg
File size    : 3444685 bytes
File date    : 2014:09:15 15:08:04
Resolution   : 4608 x 3456