Five Useful Ideas

Using ExifTool to modify metadata

09 August 2022

1. Why?

Ever since the terms and conditions fiasco with WhatsApp1, 2, the disaster that was Apple's CSAM3, I have become even more conscious about sharing images online. These images could be simple screenshots from the phone, desktop or even pictures I take on the phone or an actual camera (yes those things). The metadata that one can extract from images is beyond scary at this point. As an example, here are the parameters with filled-in values (I have Redacted a few values) from an image taken on the phone:

ExifTool Version Number         : 12.44
File Name                       : IMG_7999.jpeg
Directory                       : .
File Size                       : 2.9 MB
File Modification Date/Time     : Redacted
File Access Date/Time           : Redacted
File Inode Change Date/Time     : Redacted
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 13
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 15.6
Modify Date                     : Redacted
Host Computer                   : iPhone 13
Tile Width                      : 512
Tile Length                     : 512
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/25
F Number                        : 1.6
Exposure Program                : Program AE
ISO                             : 500
Exif Version                    : 0232
Date/Time Original              : Redacted
Create Date                     : Redacted
Offset Time                     : Redacted
Offset Time Original            : Redacted
Offset Time Digitized           : Redacted
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/25
Aperture Value                  : 1.6
Brightness Value                : -1.053634558
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 5.1 mm
Subject Area                    : 2007 1505 2213 1324
Run Time Flags                  : Valid
Run Time Value                  : 341412586472250
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : 0.02649262734 -0.9928008909 -0.09302642189
Focus Distance Range            : 0.10 - 1.03 m
Sub Sec Time Original           : 949
Sub Sec Time Digitized          : 949
Flashpix Version                : 0100
Color Space                     : Uncalibrated
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 26 mm
Scene Capture Type              : Standard
Lens Info                       : 1.539999962-5.1mm f/1.6-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 13 back dual wide camera 5.1mm f/1.6
Composite Image                 : General Composite Image
GPS Latitude Ref                : Redacted
GPS Longitude Ref               : Redacted
GPS Altitude Ref                : Redacted
GPS Speed Ref                   : Redacted
GPS Speed                       : Redacted
GPS Img Direction Ref           : Redacted
GPS Img Direction               : Redacted
GPS Dest Bearing Ref            : Redacted
GPS Dest Bearing                : Redacted
GPS Horizontal Positioning Error: Redacted
MPF Version                     : 0100
Number Of Images                : 2
MP Image Flags                  : (none)
MP Image Format                 : JPEG
MP Image Type                   : Undefined
MP Image Length                 : 228160
MP Image Start                  : 2650809
Dependent Image 1 Entry Number  : 0
Dependent Image 2 Entry Number  : 0
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : Redacted
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    :
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : Redacted
Profile Creator                 : Apple Computer Inc.
Profile ID                      : Redacted
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2022
Media White Point               : 0.96419 1 0.82489
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
Image Width                     : 4032
Image Height                    : 3024
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Run Time Since Power Up         : Redacted
Aperture                        : 1.6
Image Size                      : 4032x3024
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 5.1
Shutter Speed                   : 1/25
Create Date                     : Redacted
Date/Time Original              : Redacted
Modify Date                     : Redacted
GPS Altitude                    : Redacted
GPS Latitude                    : Redacted
GPS Longitude                   : Redacted
MP Image 2                      : (Binary data 228160 bytes, use -b option to extract)
Circle Of Confusion             : 0.006 mm
Field Of View                   : 69.4 deg
Focal Length                    : 5.1 mm (35 mm equivalent: 26.0 mm)
GPS Position                    : Redacted
Hyperfocal Distance             : 2.76 m
Light Value                     : 3.7
Lens ID                         : iPhone 13 back dual wide camera 5.1mm f/1.6

A wonderful new site by Lennart Ziburski titled "Rehthinking how technology uses our personal data" visually explores how keeping our data and AI on on-device could empower users. However, an angle that is missing in the article is even the need for some of this data to be collected in the first place. Do we really need it collected? Do we need this data to add value to our lives? One can argue some of these devices and apps allow users to customize or even minimize the amount of data collected (for pictures at least).

2. So what now?

This does mean that it becomes important to figure out ways to scrub out the metadata that is available on these pictures. That is where the wonderful world of FOSS came in and the users on Fosstodon pointed me to ExifTool. As described on it's website, ExifTool is a platform-independent Perl library plus a command-line application for reading, writing and editing meta information in a wide variety of files…. This was precisely what I needed for myself.Not only does it allow for scrubbing metadata, it allows us to modify them and add new custom user-defined tags.

3. Usage and examples

  1. Viewing metadata: As simple as passing the filename to ExifTool.

    exiftool IMGNAME
    
  2. Scrubbing: Fairly straightforward to remove all metadata from an image. The command below allows you to remove all metadata from the image. Please note that without using the -overwriteoriginal, a new file is created.

    exiftool -all= -overwrite_original IMGNAME
    

    Here is the text from man,

    -overwrite_original
           Overwrite the original FILE (instead of preserving it by adding "_original" to the
           file name) when writing information to an image.  Caution: This option should only be
           used if you already have separate backup copies of your image files.  The overwrite is
           implemented by renaming a temporary file to replace the original.  This deletes the
           original file and replaces it with the edited version in a single operation.  When
           combined with -o, this option causes the original file to be deleted if the output
           file was successfully written (ie. the file is moved instead of copied).
    
  3. Selectively writing specific tags: In my use-case, I need to specifically add CC licensing details to my image as I have decided to share all my images with those licenses. the example to do so is fairly simple.

    exiftool -overwrite_original -XMP-cc:license="http://creativecommons.org/licenses/by-sa/4.0/" -XMP-cc:AttributionName="" -XMP-cc:AttributionURL="" -xmp:usageterms="This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License http://creativecommons.org/licenses/by-sa/4.0/"
    

    This allows me to share an image with these terms and they pop-up whenever anyone views them with any metadata tool across the board.

Footnotes: