Remove Exif info in jpg image under command line

Exif, stands for Exchangeable image file format, which we usually use to recognize the camera manufacturer, model, exposure time in a digital photo, it is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (or digital devices in nowadays, like smart phones and tablets), scanners and other systems handling image and sound files recorded by digital cameras.

406px-Konqueror_Exif_data.jpg

Exif in JPEG image example from Wikipedia: https://en.wikipedia.org/wiki/File:Konqueror_Exif_data.jpg

Exif can help us know more about the photos and audios, but may also leaks the valuable and privacy info if you don’t want to let others know that you just want to share pictures with others, it will also cost a small disk space, but uf you don’t need it or you don’t want it, it’s also a waste of disk space, so you may want to remove that info like me in some situation. Here is the steps to remove Exif under command line.

Install exiftool:

Make sure you can now use exiftool:

If you would like to see the current exist info, use this command, filename.jpg is the picture you want to manipulate:

Now you can remove Exif info:

By default, it will backup your file to filename_oringinal, like filename.jpg -> filename.jpg_original, so you don’t need to worry about the backup, if you don’t want it, you can also add parameter -overwrite_original to prevent to backup file been generated.

After you remove the Exif info, you will find the modified file be a little bit smaller now.

If you take a look at its info, you will find that there are only some basic info remaing:

That’s all.

Use ‘jpegoptim’ to optimize/re-compress your jpg images

I use optipng and jpegoptim to help me compress/optimize my jpg/png images.

For png images re-compression, please refer to:

https://www.peterdavehello.org/2015/05/use-optipng-to-optimize-re-compress-your-png-images-losslessly/

jpegoptim supports many platform, incluing Solaris, Mac OS X and Windows, of course FreeBSD and Linux, here is its git repository on GitHub:
https://github.com/tjko/jpegoptim

How to install?

FreeBSD:

For Debian/Ubuntu based GNU/Linux:

For CentOS/RHEL/Fedora based GNU/Linux

(on CentOS/RHEL, please enable EPEL repo first)

How to use?

By default, jpegoptim uses ‘lossless‘ mode to re-compress the jpeg images, which means the optimized images will have the same quality just like it was, to make the images smaller, you can use -m<quality>, --max=<quality> to enable lossy optimize by setting its quality, the valid range is 0 – 100, for example, set quality = 90:

Note that the files that already have lower quality setting will be compressed using the lossless optimization method.

You can also use find to help you compress all the jpeg images:

Using this picture on Wikipedia as an exmaple: https://wikipedia.org/wiki/File:JPEG_example_donkey_100.jpg

jpegoptim-example

Before the compression, 36239 bytes (about 36 KB):

JPEG_example_donkey_100
After the compression, 10145 bytes (about 10 KB):

JPEG_example_donkey_80

Can you recognize which one has better/lower quality? :D