LoginSignup
22
18

More than 5 years have passed since last update.

テスト用にEXIF情報を加工するときに知っておきたいExifTool

Last updated at Posted at 2014-06-12

Macの標準アプリのプレビュー.appなどでExif情報をカジュアルに閲覧できることは周知の事実ですが、Exifを加工する機能を作っているときなんかに、Exif情報を加工したいなーと思うことはないでしょうか。

それ、ExifToolを使えばできるよ!
(Windows、Mac、Linuxに対応しています)

使い方

画像に設定されているExif情報を見る

$ exiftool sample.jpg
ExifTool Version Number         : 9.63
File Name                       : sample.jpg
Directory                       : .
File Size                       : 197 kB
File Modification Date/Time     : 2014:06:12 10:46:53+09:00
File Access Date/Time           : 2014:06:12 11:09:53+09:00
File Inode Change Date/Time     : 2014:06:12 10:54:48+09:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Exif Byte Order                 : Big-endian (Motorola, MM)
Color Space                     : sRGB
Exif Image Width                : 1024
Exif Image Height               : 768
Image Width                     : 1024
Image Height                    : 768
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 1024x768

Exif情報をExifToolの項目名ベースで見る

$ exiftool -s sample.jpg
ExifToolVersion                 : 9.63
FileName                        : sample.jpg
Directory                       : .
FileSize                        : 197 kB
FileModifyDate                  : 2014:06:12 10:46:53+09:00
FileAccessDate                  : 2014:06:12 11:10:23+09:00
FileInodeChangeDate             : 2014:06:12 10:54:48+09:00
FilePermissions                 : rw-rw-rw-
FileType                        : JPEG
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ResolutionUnit                  : None
XResolution                     : 1
YResolution                     : 1
ExifByteOrder                   : Big-endian (Motorola, MM)
ColorSpace                      : sRGB
ExifImageWidth                  : 1024
ExifImageHeight                 : 768
ImageWidth                      : 1024
ImageHeight                     : 768
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 1024x768

Exif情報を編集するときは、このExifTool内での項目名を指定します。

Exif情報を編集する

Exifの項目名一覧ページを参考にExif情報を加工します。

試しに「画像入力機器のメーカー名」を「SonicGarden」に変更してみると、以下のようになります。

$ exiftool -Make="SonicGarden" sample.jpg
    1 image files updated
$ exiftool -s sample.jpg                                                                                                                                                                                                                          ExifToolVersion                 : 9.63
FileName                        : sample.jpg
Directory                       : .
FileSize                        : 197 kB
FileModifyDate                  : 2014:06:12 11:13:41+09:00
FileAccessDate                  : 2014:06:12 11:13:43+09:00
FileInodeChangeDate             : 2014:06:12 11:13:41+09:00
FilePermissions                 : rw-rw-rw-
FileType                        : JPEG
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ResolutionUnit                  : None
XResolution                     : 1
YResolution                     : 1
ExifByteOrder                   : Big-endian (Motorola, MM)
Make                            : SonicGarden
ColorSpace                      : sRGB
ExifImageWidth                  : 1024
ExifImageHeight                 : 768
ImageWidth                      : 1024
ImageHeight                     : 768
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 1024x768

ちゃんと変更されていますね!

一番需要が多そうな画像の向きの変更は以下のようにしてやります。

$ exiftool -Orientation#=3 sample.jpg
    1 image files updated
$ exiftool -s sample.jpg
ExifToolVersion                 : 9.63
FileName                        : sample.jpg
Directory                       : .
FileSize                        : 197 kB
FileModifyDate                  : 2014:06:12 11:16:03+09:00
FileAccessDate                  : 2014:06:12 11:16:04+09:00
FileInodeChangeDate             : 2014:06:12 11:16:04+09:00
FilePermissions                 : rw-rw-rw-
FileType                        : JPEG
MIMEType                        : image/jpeg
JFIFVersion                     : 1.01
ResolutionUnit                  : None
XResolution                     : 1
YResolution                     : 1
ExifByteOrder                   : Big-endian (Motorola, MM)
Make                            : SonicGarden
Orientation                     : Rotate 180
ColorSpace                      : sRGB
ExifImageWidth                  : 1024
ExifImageHeight                 : 768
ImageWidth                      : 1024
ImageHeight                     : 768
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:0 (2 2)
ImageSize                       : 1024x768

Orientationが「Rotate 180」になりました。

引数に数字を指定する場合は=ではなく#=で指定しないとエラーになるので気をつけてください。

ご参考までに、Orientationは引数に設定する数字の値によって、以下のような設定になります。

1 = Horizontal (normal) 
2 = Mirror horizontal 
3 = Rotate 180 
4 = Mirror vertical 
5 = Mirror horizontal and rotate 270 CW 
6 = Rotate 90 CW 
7 = Mirror horizontal and rotate 90 CW 
8 = Rotate 270 CW
22
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
18