EXIF data is great for knowing more about an image, but it can also leak information you don’t want to leak if the picture gets out there. EXIF stands for Exchangeable Image File. It’s basically a way to embed camera settings, location data, etc. into an image. This is great for you, but not so great from a privacy perspective if you aren’t careful.
Let’s learn how to both view this data and remove it on Debian and Ubuntu Linux. The instructions for installing are specific to Debian and Ubuntu, but the same packages most likely exist on your flavor of choice, but might be called something else. This article just covers how to view the data and how to get rid of it and some alternatives.
Viewing EXIF Data
Imagemagick is a command line tool which is extremely powerful for image manipulation and provides libraries for many different languages for embedded image processing in applications. It can convert images to different formats, resize, transform, and identify information about images. It’s also great for bulk image processing if you know how to script. Install Imagemagick by running:
sudo apt install imagemagick
See this article for more information about apt on Ubuntu and Debian.
Once that’s installed, we can go about viewing information about the image. If you run:
identify -verbose "[path to image]"
You will get a huge block of various information about the image. If you just want the EXIF data, pipe this into grep and find EXIF data using:
identify -verbose "[path to image]" | grep "exif"
This will throw back the EXIF data which looks like:
$ identify -verbose june60.JPG | grep "exif"
exif:ApertureValue: 193685/85136
exif:BrightnessValue: -76371/50342
exif:ColorSpace: 1
exif:ComponentsConfiguration: 1, 2, 3, 0
exif:DateTime: 2019:11:02 12:38:59
exif:DateTimeDigitized: 2019:11:02 12:38:59
exif:DateTimeOriginal: 2019:11:02 12:38:59
...
![](https://somedudesays.com/wp-content/uploads/2019/11/puzzle-140904_640.jpg)
There’s nothing identifying in the block I copied, but there can be location coordinates and similar further in, as well as camera information which can be somewhat identifying when put together. If you’re trying to protect your privacy and avoiding metadata analysis, you want to strip the EXIF data.
The date combined with the location data means that someone could know where I was and when, which can show patterns in my life, and show where I might be when taken in aggregate. Other data added in with identifying information can further narrow this down giving a clear picture of where you are and what you’re doing over a span of time. Think of this next time you put a picture online when you’re on vacation. Someone might be watching to see where you are and can know you’re away from home from the EXIF data.
Stripping the EXIF Data with Imagemagick
If you don’t want to install anything new, or you don’t care about a quality hit (see below for more about this), you can use Imagemagick to strip EXIF data from an image. To just strip the EXIF data from the image, run:
convert -strip "[path to image]"
This does impact the quality of the image because it does reconvert it. Each reconvert of an image will affect the quality of the image. If you reconvert enough, eventually the image will be unrecognizable unless it is lossless (though it can affect lossless images if you perform any operation on the image itself). I use Imagemagick to resize images from my camera, so I just chain the commands as follows:
convert "[image]" -resize [percentage you want it resized to]% -strip "[new name].jpg"
Which can look something like:
convert "myjpg.jpg" -resize 50% -strip "myjpg-reduced.jpg"
This allows me to skip stripping the EXIF, then converting the image. If the image is already the right size, you probably want to use something like Exiv2 instead of Imagemagick.
Using Exiv2 to Strip EXIF Data
Exiv2 is an image metadata manipulation tool. It supports basically every common format, and a lot of less common formats as well. It can’t do everything for every format, but I’ve never used a format it can’t work with. Run the following to install it on Debian or Ubuntu:
sudo apt install exiv2
To remove EXIF data, all you need to do is run:
exiv2 rm "[path to image]"
This will fully clear out the EXIF data for the image without reconverting the image or even touching the image otherwise. This is what I use for images which are already the right size. There is no quality hit with this tool since it doesn’t touch the image data itself.
Conclusion
Both Imagemagick and Exiv2 are far, far more powerful than I could fit in a single blog post (or even dozens). They allow image manipulation on different fronts and are great command line tools for working with images and even for batch jobs using Bash or similar to process large folders of images. These tools are predictable and reliable and it’s good to at least be somewhat familiar with them if you work with images. Check out the man pages for each, or various guides online for more of their functions. We haven’t even begun to scratch the surface in this article.
Featured image by Gerd Altmann from Pixabay