Paul Chris Jones's coding blog
PHP
JS

Removing metadata from images

16th April 2020

I have recently discovered the joys of exif metadata.

You just download any image from the internet and run

exiftool image_filename.jpg

and BAM! You have a bunch of data about that image.

image metadata

Sometimes it will even show the location where the image was taken. From this, you can work out where someone lives. Obviously, that isn't good if you're the one who uploaded the image. You don't want strangers on the internet knowing the location of your house. I believe therefore that most images should be stripped of their metadata before being uploaded to the web.

How to remove metadata from images

Fortunately, there's an easy way to remove metadata from an image:

exiftool -all= image_filename.jpg

That command erases all the metadata from an image. It also has the added benefit of making the file smaller since it's no longer carrying metadata.

Note the command creates a copy however called image_filename.jpg_original. You can delete the original with

rm -f *original

If you want to erase the metadata of all the images in a directory, you can do:

exiftool -all= *

Leave a comment