There's a lot to learn about image files on the command line, from verifying file format to finding out where and when photos were taken and maybe even getting an unusual view of what they look like. Credit: Moini While the best way to view or manipulate image files on Linux is to open them on your desktop for viewing or manipulating with tools like Gimp, there are quite a few ways to get important details on the command line. Identifying image type by file extension In general, image files can be identified on the command line by listing their names. Clearly “.jpg” represents a jpeg file, “.png” a portable network graphics file, “.gif” a graphics interchange format file, “.tiff” a tagged image file and so on. $ ls -l images -rw-rw-r--. 1 shs shs 256093 Jul 15 2018 mycats.jpg -rw-r-----. 1 shs shs 784238 Jul 15 2018 mycats.png -rw-rw-r--. 1 shs shs 6760 Jul 15 2018 arrow.jpg -rw-r-----. 1 shs shs 8853 Jul 15 2018 arrow.png Nearly all of the time you can rely on file extensions accurately reporting the file type, but there’s more you can do with additional commands. Identifying images with the file command The file command can identify image file types by extracting data from the files themselves. $ file Emmy.jpg Emmy.jpg: JPEG image data, progressive, precision 8, 704x584, components 3 The file below is clearly a jpg file in spite of its name. The output from the file command reports this. $ file camper.png camper.png: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=11, manufacturer=samsung, model=SM-G935V, orientation=upper-left, xresolution=164, yresolution=172, resolutionunit=2, software=GIMP 2.8.18, datetime=2018:04:30 07:56:54, GPS-Data], progressive, precision 8, 3465x2717, components 3 For most jpg files these days, the file command will show a lot more details as in the examples above and below. This output includes the file type, resolution details and quite a bit of information about where the image came from and when it was taken. $ file tulip_poplar.jpg tulip_poplar.jpg: JPEG image data, Exif standard: [TIFF image data, big-endian, direntries=11, yresolution=146, xresolution=154, model=SM-A526U, height=2448, manufacturer=samsung, software=A526USQS5CVC9, orientation=upper-left, datetime=2022:05:17 19:58:50, width=2448], baseline, precision 8, 2448x2448, components 3 As you can see from the output above, the tulip_poplar.jpg file was taken on May 17, 2022, with a Samsung cell phone, Viewing image details using an octal dump You can view some image details using the od -bc (octal dump) command. However, looking beyond the first couple of lines will also display portions of the image itself that won’t be helpful. The first part of the file contains “meta information” (data that describes the content rather than the image content itself). For example, the second line below identifies the file as a png file. $ od -bc coconuts.png | head -4 0000000 211 120 116 107 015 012 032 012 000 000 000 015 111 110 104 122 211 P N G r n 032 n Related content how-to Making bash aliases easy to manage Aliases provide an easy way to reuse complicated or often-used commands. By Sandra Henry-Stocker Mar 21, 2024 4 mins Linux how-to Determining leap years on Linux Leap years are not quite as regular as we might have believed. A fairly simple Linux script can tell you whether a year will be a leap year or not. By Sandra Henry-Stocker Mar 18, 2024 4 mins Linux how-to How to ensure users periodically update their passwords on Linux Requiring password changes is a common security practice, and Linux systems admins can use the chage command to view and change password expiration information. By Sandra Henry-Stocker Mar 14, 2024 3 mins Linux news Linux hits 4% desktop user share While the desktop is not Linux's claim to fame, Linux still offers a huge number of distributions that can make your desktop computer work just like you'd want. By Sandra Henry-Stocker Mar 11, 2024 2 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe