How to get information about an image (picture) from the Linux command-line?
For some image formats you can just use the file
command:
$ file MyPNG.png
MyPNG.png: PNG image, 681 x 345, 8-bit/color RGB, non-interlaced
Not all image formats report the size (JPEG most notably doesn't):
$ file MyJpeg.jpg
MyJpeg.jpg: JPEG image data, JFIF standard 1.01
For those you will have to use something more elaborate, like:
$ convert MyJpeg.jpg -print "Size: %wx%h\n" /dev/null
Size: 380x380
The convert
command is part of the ImageMagick package.
The best way to get this information is by using the identify
command:
$ identify image.png
or only size atributes
$ identify -format "%wx%h" photo.jpg
It is part of ImageMagick, which you can install on Ubuntu like so:
$ sudo apt-get install imagemagick
exiv2 is "the tool" to get information from picture files:
~$exiv2 myimage.jpg
outputs:
File name : myimage.jpg
File size : 1196944 Bytes
MIME type : image/jpeg
Image size : 2592 x 1944
Camera make : LG Electronics
Camera model : LG-P970
Image timestamp : 2013:05:19 17:27:06
Image number :
Exposure time : 1/9 s
Aperture :
Exposure bias : 0 EV
Flash : Yes, compulsory
Flash bias :
Focal length : 3.7 mm
Subject distance:
ISO speed : 745
Exposure mode :
Metering mode : Average
Macro mode :
Image quality :
Exif Resolution :
White balance : Auto
Thumbnail : image/jpeg, 13776 Bytes
Copyright :
Exif comment :