Hacker Public Radio

HPR3564: Removing EXIF data from an image


Listen Later

Introduction
I’m writing a script to process image files sent in by HPR hosts with their shows. One of the things the script does is to strip Exif metadata from such images. That’s because this metadata may contain details that could identify the creator of the image - their camera, their location, and other things. Many people will be alert to this, but in case anything slips through it seems a courtesy to anonymise images sent to HPR.
As I was implementing this I realised that one piece of Exif data: 'Orientation', can’t just be removed. Sometimes images are created with a particular orientation by the camera but are written with an Exif orientation setting that shows another orientation. If this is just removed the image might be shown wrongly.
This short episode describes the journey I had learning about this issue and finding how to get round it.
The Problem
A show was sent in early March 2022 which had three images with orientation values in the Exif metadata. They had apparently been taken with one orientation but were being rotated for viewing.
I later discovered that the orientation setting can be viewed with the exiftool command:
$ exiftool -orientation testimage.jpg
Orientation : Rotate 90 CW
You can find information about the Orientation tag on the ExifTool web site.
The actual image in this case is rotated 90° anti-clockwise (the top of the image is to the left) and this needs to be reversed. The setting 'Rotate 90 CW' causes it to be displayed after rotating 90° in the clockwise direction. The actual value for this setting is 6.
The problem is that removing all the Exif data causes such an image to revert to its raw state as explained below.
Investigation
Demonstration
It took me a little while to understand this problem because I couldn’t find a good explanation of what was going on.
I found a repository on GitHub which would take a picture and generate all of the possible Exif orientations from it. I used it to generate pictures from one (a thumbnail) I used in an old HPR show. Here’s the original picture with an orientation setting of 6 (Rotate 90 CW), and then with the Exif metadata removed.
Original image with orientation 6
Same image with Exif stripped
Methods used to fix this
I found and installed some tools:
jpegexiforient - reads or writes the Exif Orientation Tag
exifautotran - transforms Exif files so that Orientation becomes 1
jpegtran - lossless transformation of JPEG files
Note that these only operate on JPEG images.
The exifautotran tool is a shell script that uses jpegexiforient to find the orientation and jpegtran to undo whatever rotation (or other transformation) has been defined.
Reading the exifautotran script helped me understand all of this, but I did not use these tools in the end.
In the script I had written to manage images I also needed to do other image operations:
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

290 Listeners

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec by Jerry Bell and Andrew Kalat

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec

372 Listeners

LINUX Unplugged by Jupiter Broadcasting

LINUX Unplugged

268 Listeners

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast) by Johannes B. Ullrich

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast)

651 Listeners

Curious Cases by BBC Radio 4

Curious Cases

821 Listeners

The Strong Towns Podcast by Strong Towns

The Strong Towns Podcast

423 Listeners

Late Night Linux by The Late Night Linux Family

Late Night Linux

164 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,059 Listeners

Cybersecurity Today by Jim Love

Cybersecurity Today

179 Listeners

CISO Series Podcast by David Spark, Mike Johnson, and Andy Ellis

CISO Series Podcast

189 Listeners

TechCrunch Daily Crunch by TechCrunch

TechCrunch Daily Crunch

42 Listeners

Strict Scrutiny by Crooked Media

Strict Scrutiny

5,800 Listeners

2.5 Admins by The Late Night Linux Family

2.5 Admins

98 Listeners

Cyber Security Headlines by CISO Series

Cyber Security Headlines

139 Listeners

What the Hack? by DeleteMe

What the Hack?

228 Listeners