CLI tip 1: remove metadata from images
Want to remove metadata (DateTime, Model, Orientation, ShutterSpeedValue, etc) from your images? You can use mogrify
or convert
tools provided by ImageMagick.
GUI image viewer applications will usually allow you to see some of the image metadata. You can also use the identify
command line tool to get all the metadata:
# remove 'head' to get the entire list of metadata
$ identify -verbose insect.jpg | grep 'exif' | head
exif:ApertureValue: 113/32
exif:ColorSpace: 1
exif:ComponentsConfiguration: 1, 2, 3, 0
exif:CompressedBitsPerPixel: 3/1
exif:CustomRendered: 0
exif:DateTime: 2016:12:03 11:26:10
exif:DateTimeDigitized: 2016:12:03 11:26:10
exif:DateTimeOriginal: 2016:12:03 11:26:10
exif:DigitalZoomRatio: 4000/4000
exif:ExifOffset: 240
And here's how you can remove such metadata from images:
# to create a new image with metadata removed
$ convert -strip insect.jpg op.jpg
# to modify the input image itself
$ mogrify -strip insect.jpg
You can also pass multiple images to mogrify
:
$ mogrify -strip *.jpg
Note that the image size after metadata removal may vary because of recompression.
Video demo:
Further Reading:
- ImageMagick — create, edit, compose, or convert digital images
- How can I read and remove meta (exif) data from my photos using the command line?
- How to strip metadata from image files
- What does mogrify mean?
- wikipedia: Exif