As provided in the rest of the answers you can use identify
command with -verbose
flag.
Below is a way to select specific information from the identify
output, which is (almost) yaml
format.
sudo pip install yq
# OR
pip install --user yq
# note: sed is used to remove what breaks yaml format (first line only).
identify -verbose image.png | sed 's/^Image:.*/Image:/' \
| yq -Y '.Image|{"Format","Geometry","Colorspace","Depth","Channel depth","Filesize","Number pixels"}'
output:
Format: JPEG (Joint Photographic Experts Group JFIF format)
Geometry: 1000x714+0+0
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Filesize: 125KB
Number pixels: 714K
json output (without -Y flag):
{
"Format": "JPEG (Joint Photographic Experts Group JFIF format)",
"Geometry": "1000x714+0+0",
"Colorspace": "sRGB",
"Depth": "8-bit",
"Channel depth": {
"red": "8-bit",
"green": "8-bit",
"blue": "8-bit"
},
"Filesize": "125KB",
"Number pixels": "714K"
}
Note: tesed with .jpg
.png
.gif
,.tif
. Also does not seem to work with .svg
(identify
output is differrent)