Working with EXIF-data in jpg, png, and webp files
- Category: Servers
- Published: Thursday, 10 December 2020 16:03
- Written by Super User
- Hits: 1439
Almost all image files have the ability to store additional data, such as image size, creation time, geo-coordinates and so on.
It is also possible to add additional parameters - description, copyright and more.
There are EXIF data
Exchangeable image file format - a standard that defines the format of the description of auxiliary meta-information for image and sound files and used by digital cameras (including those in smartphones), scanners and other systems.
By the way, there is insufficient evidence that search engines use exif-image data on sites to rank the site and search optimizing.
Now let's see how to add or change EXIF-data
Metadata in jpg and png files
For these purposes, Linux has an exiftool utility that can output or modify metadata in png and jpg files.
To install it, you need to execute a command
apt install libimage-exiftool-perl
When executing a command
will display the current information that is stored in this file, something like
ExifTool Version Number : 10.80
File Name : image.jpg
Directory : .
File Size : 156 kB
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Creator Tool : Adobe Photoshop CC 2014 (Windows)
Profile CMM Type : Linotronic
Color Transform : YCbCr
Image Width : 580
Image Height : 400
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
Image Size : 580x400
Megapixels : 0.232
this is only part of the output, because the full output is too long.
If we want to add or change a certain field (in our case - ImageDescription), we will do it with the command
exiftool -ImageDescription="My best image" image.jpg
Similarly, you can change or add any other field, such as copyright
If you want to clear the metadata, you can run
exiftool -all= image.jpg To delete a specific field exiftool -ImageDescription= image.jpg More precisely, in this way we do not delete the field itself, but simply delete the data in it.
Metadata in webp files
The exiftool utility does not yet support webp files and we need another utility to work with them - webpmux
To install it, execute the command
apt install webp
This utility is not able to display metadata, but only saves them in the specified file
webpmux -get exif image.webp -o image_metadata.exif
If an error occurs while executing this command, it means that there are no metadata in the file
To set the data we need in a webp file, we first need to create a metadata file (such as file.exif) and write something like
copyright: 2020© yakim.org.ua
After that, execute the command
webpmux -set exif file.exif image.webp -o image.webp
Note that the source file has the ability not to change, but to create a new one and already add metadata there.