36.28 Remove Metadata from Image

20190907 When sharing photos publicly it could be useful to ensure there is no personal information included in the metadata. Such metadata can be removed before sharing the photo.

Let’s check the meta data of a photo:

$ exiftool photo.jpg
ExifTool Version Number         : 10.80
File Name                       : photo.jpg
Directory                       : .
File Size                       : 47 kB
...
File Permissions                : rw-r-----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : samsung
Camera Model Name               : SM-G930F
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : GIMP 2.8.22
...
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/50
F Number                        : 1.7
Exposure Program                : Program AE
ISO                             : 100
Exif Version                    : 0220
...
Image Width                     : 153
Image Height                    : 600
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:4:0 (1 2)
Aperture                        : 1.7
Flash                           : No Flash
Image Size                      : 153x600
Megapixels                      : 0.092
Scale Factor To 35 mm Equivalent: 6.2
Shutter Speed                   : 1/50
...
Hyperfocal Distance             : 2.14 m
Light Value                     : 7.2

That’s a lot of information. Before sharing a photo, and particularly if you want to remove any potentially private information, use the -all= option of exiftool. This will set many meta tags to the empty string.

$ exiftool -all= photo.jpg
    1 image files updated

Now check the photo gain:

$ exiftool photo.jpg
ExifTool Version Number         : 10.80
File Name                       : photo.jpg
Directory                       : .
File Size                       : 40 kB
...
File Permissions                : rw-r-----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Image Width                     : 153
Image Height                    : 600
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:4:0 (1 2)
Image Size                      : 153x600
Megapixels                      : 0.092


Your donation will support ongoing availability and give you access to the PDF version of the book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.