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 How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe