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 examine files on Linux Linux provides very useful options for viewing file attributes, such as owners and permissions, as well as file content. By Sandra Henry Stocker Oct 24, 2024 6 mins Linux how-to 8 easy ways to reuse commands on Linux Typing the same command again and again can become tiresome. Here are a number of ways you can make repeating commands – or repeating commands but with some changes – a lot easier than you might expect. By Sandra Henry-Stocker Oct 15, 2024 5 mins Linux news SUSE Edge upgrade targets Kubernetes and Linux at the edge SUSE Edge 3.1 includes a new stack validation framework and an image builder tool that are aimed at improving the scalability and manageability of complex Kubernetes and Linux edge-computing deployments. By Sean Michael Kerner Oct 15, 2024 6 mins Edge Computing Linux Network Management Software how-to Lesser-known xargs command is a versatile time saver Boost your Linux command line options and simplify your work with xargs, a handy tool for a number of data manipulation tasks. By Sandra Henry Stocker Oct 11, 2024 6 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe