Metadata is basically data about data. Think about it as information that describes a file and provides a deeper understanding of the data you are looking at.
It can be used to index multiple files in a database collection or table, it makes it easier to categorize and return search results based on a custom query.
Strictly related to image files, metadata provides information that can be divided into 3 categories:
– Administrative metadata – includes copyright info, details about the owner, type of license, and permitted usage terms
– Technical metadata – the exact characteristics of the photograph, including, but not limited to: camera manufacturer and model; image resolution, format, and size; photographer “secrets” – ISO, shutter speed, white balance, lens aperture. This info is generated by the camera when the picture is taken.
– Descriptive metadata – is, most of the time, manually added at a later stage, but some modern cameras can automatically include exact location by using GPS capabilities. Other descriptive info could be the photographer’s name, the picture title, the collection it is part of, etc.
Knowing these details helps you understand that metadata is important for sorting, searching, analyzing, licensing, and, why not, learning photography or image editing details and techniques.
One important thing to keep in mind is that metadata validity is not bulletproof, it can easily be removed or modified.
Linux Tools for Metadata Inspection
The easiest tool and, generally, included in every Linux distribution and version is
file is used to determine the type of any file in Linux. The file I am using in this tutorial is simply called image.jpg and we are about to find a lot of details about it.
$ file image.jpg image.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 300x300, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=10, PhotometricIntepretation=RGB, manufacturer=NIKON CORPORATION, model=NIKON D750, orientation=upper-left, xresolution=164, yresolution=172, resolutionunit=2, software=Adobe Photoshop 22.2 (Windows), datetime=2021:06:28 23:19:23], baseline, precision 8, 4016x6016, frames 3
We can clearly spot some general info which can be understood regardless of your computers or photography knowledge. We see the picture was last modified on 28 June 2021, at 23:19:23, it was taken using a Nikon camera, model D750, it has a 4016×6016 pixels size and someone used a Windows version of the Adobe Photoshop 22.2 software to edit it.
This is the basic metadata that the
file command can output. Let’s go deeper, let’s get more metadata. We can do this using a tool called
identify which is part of the
Installation on Ubuntu, Debian, and Mint:
$ sudo apt install imagemagick -y
On Fedora and CentOS:
$ sudo dnf install imagemagick -y
I am using CentOS 8 to demonstrate this and the
epel (Extra Packages for Enterprise Linux) repository is needed:
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y $ sudo yum install ImageMagick -y
To check, simply type
Using it on a file:
$ identify image.jpg image.jpg JPEG 4016x6016 4016x6016+0+0 8-bit sRGB 13.6245MiB 0.000u 0:00.003
Still, basic information is provided. Let’s ask for more using the
$ identify -verbose image.jpg Image: image.jpg Format: JPEG (Joint Photographic Experts Group JFIF format) Mime type: image/jpeg Class: DirectClass Geometry: 4016x6016+0+0 Resolution: 300x300 Print size: 13.3867x20.0533 Units: PixelsPerInch Colorspace: sRGB Type: TrueColor Base type: Undefined Endianess: Undefined Depth: 8-bit Channel depth: red: 8-bit green: 8-bit blue: 8-bit Channel statistics: Pixels: 24160256 Red: min: 0 (0) max: 255 (1) mean: 137.233 (0.538169) standard deviation: 60.7126 (0.238089) kurtosis: -1.13716 skewness: 0.165882 entropy: 0.946998 Green: min: 0 (0) max: 255 (1) mean: 128.666 (0.504571) standard deviation: 53.7448 (0.210764) kurtosis: -0.659069 skewness: 0.235477 entropy: 0.949436 Blue: min: 0 (0) max: 255 (1) mean: 124.86 (0.489648) standard deviation: 52.6795 (0.206586) kurtosis: -0.430637 skewness: 0.302093 entropy: 0.948317 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 130.253 (0.510796) standard deviation: 55.7123 (0.21848) kurtosis: -0.770376 skewness: 0.258289 entropy: 0.94825 Rendering intent: Perceptual Gamma: 0.454545 Chromaticity: red primary: (0.64,0.33) green primary: (0.3,0.6) blue primary: (0.15,0.06) white point: (0.3127,0.329) Background color: white Border color: srgb(223,223,223) Matte color: grey74 Transparent color: black Interlace: None Intensity: Undefined Compose: Over Page geometry: 4016x6016+0+0 Dispose: Undefined Iterations: 0 Compression: JPEG Quality: 99 Orientation: TopLeft Profiles: Profile-8bim: 104 bytes Profile-exif: 936 bytes Profile-iptc: 63 bytes City[1,90]: 0x00000000: 254700 -%G unknown[2,0]: unknown[2,63]: 125737 unknown[2,62]: 20210618 Created Date[2,55]: 20210618 Created Time[2,60]: 125737 Profile-xmp: 8181 bytes Properties: date:create: 2021-10-17T11:46:33+00:00 date:modify: 2021-07-02T07:15:02+00:00 exif:ApertureValue: 43728/14719 exif:BodySerialNumber: 6157677 exif:ColorSpace: 1 exif:Contrast: 0 exif:CustomRendered: 0 exif:DateTime: 2021:06:28 23:19:23 exif:DateTimeDigitized: 2021:06:18 12:57:37 exif:DateTimeOriginal: 2021:06:18 12:57:37 exif:DigitalZoomRatio: 1/1 exif:ExifOffset: 232 exif:ExifVersion: 48, 50, 51, 48 exif:ExposureBiasValue: 0/1 exif:ExposureMode: 0 exif:ExposureProgram: 4 exif:ExposureTime: 1/160 exif:FileSource: 3 exif:Flash: 16 exif:FNumber: 14/5 exif:FocalLength: 55/1 exif:FocalLengthIn35mmFilm: 55 exif:FocalPlaneResolutionUnit: 3 exif:FocalPlaneXResolution: 2123919/1268 exif:FocalPlaneYResolution: 2123919/1268 exif:GainControl: 0 exif:LensModel: TAMRON SP 24-70mm F2.8 Di VC USD A007N exif:LensSpecification: 24/1, 70/1, 14/5, 14/5 exif:LightSource: 0 exif:Make: NIKON CORPORATION exif:MaxApertureValue: 3/1 exif:MeteringMode: 5 exif:Model: NIKON D750 exif:PhotographicSensitivity: 320 exif:PhotometricInterpretation: 2 exif:PixelXDimension: 4016 exif:PixelYDimension: 6016 exif:Saturation: 0 exif:SceneCaptureType: 0 exif:SceneType: 1 exif:SensingMethod: 2 exif:SensitivityType: 2 exif:Sharpness: 0 exif:ShutterSpeedValue: 24609/3361 exif:Software: Adobe Photoshop 22.2 (Windows) exif:SubjectDistanceRange: 0 exif:SubSecTimeDigitized: 68 exif:SubSecTimeOriginal: 68 exif:WhiteBalance: 0 jpeg:colorspace: 2 jpeg:sampling-factor: 1x1,1x1,1x1 signature: 1cbb0d090faf090e866cbab6ec3b405d6118638d144d42c1b07c52bbfc8aa46e Artifacts: filename: image.jpg verbose: true Tainted: False Filesize: 13.6245MiB Number pixels: 24.1603M Pixels per second: 48.6879MB User time: 0.460u Elapsed time: 0:01.496 Version: ImageMagick 6.9.10-86 Q16 x86_64 2020-01-13 https://imagemagick.org
Whoa! That is a lot, right? You can find everything there to know about the image file in the above list.
If you are into photography, try using
|grep -i exif after the command, you will get what you are looking for.
$ identify -verbose image.jpg |grep -i exif
Speaking about EXIF, EXIF means Exchangeable Image File Format, and there is a utility called ExifTool.
Installation on Debian, Ubuntu, Mint, etc:
$ sudo apt install libimage-exiftool-perl -y
On CentOs you will still need the EPEL repository described earlier:
$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y $ sudo yum install perl-Image-ExifTool -y
exiftool image.jpg and you will get another long list of each detail included in the image file’s metadata section. The big advantage of using this tool is that it allows you to modify the metadata.
I will provide just one simple example which you can easily adapt for other keys in the metadata list. I will modify this image’s creation date.
$ exiftool -FileModifyDate -CreateDate image.jpg File Modification Date/Time : 2021:07:02 07:15:02+00:00 Create Date : 2021:06:18 12:57:37
The command used to modify “Create Date”:
$ exiftool "-CreateDate=2018:12:23 00:05:42" image.jpg 1 image files updated
Checking it was successful:
$ exiftool -FileModifyDate -CreateDate image.jpg File Modification Date/Time : 2021:10:17 13:21:33+00:00 Create Date : 2018:12:23 00:05:42
Please note that this command does not modify the creation date and time of the file itself, just the info (metadata) of the image creation date and time.
It’s easy as that you can now get all the “hidden” info you need and also modify it.