Working with image files on the Linux command line

Uncategorized

While the best method to see or control image files on Linux is to open them on your desktop for seeing or manipulating with tools like Gimp, there are many methods to get important details on the command line.Identifying image

type by file extension In basic, 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 256093 Jul 15 2018 mycats.jpg -rw-r —–. 1 shs 784238 Jul 15 2018 mycats.png -rw-rw-r–. 1 shs 6760 Jul 15 2018 arrow.jpg -rw-r —–. 1 shs 8853 Jul 15 2018 arrow.png

Nearly all of the time you can depend on file extensions precisely reporting the file type, but there’s more you can do with extra commands.Identifying images with the

file command The file command

can recognize image file types by extracting data from the files themselves.$submit Emmy.jpg Emmy.jpg: JPEG image information, progressive, accuracy 8, 704×584, elements 3

The file below is plainly a jpg file in spite of its name. The output from the file command reports this.

$ file camper.png camper.png: JPEG image information, JFIF basic 1.01, resolution (DPI), density 72×72, sector 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 application=GIMP 2.8.18, datetime=2018:04:30 07:56:54, GPS-Data], progressive, precision 8, 3465×2717, elements 3

For most jpg files these days, the file command will reveal a lot more details as in the examples above and listed below. This output consists of the file type, resolution details and a fair bit of details about where the image came from and when it was taken.

$ file tulip_poplar. jpg tulip_poplar. jpg: JPEG image data, Exif requirement: [TIFF image data, big-endian, direntries=11, yresolution=146, xresolution=154, design=SM-A526U, height=2448, maker=samsung, software=A526USQS5CVC9, orientation=upper-left, datetime=2022:05:17 19:58:50, width=2448], baseline, accuracy 8, 2448×2448, parts 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 information using an octal dump

You can see some image information using the od -bc (octal dump) command. Nevertheless, looking beyond the first number of lines will also show parts of the image itself that won’t be helpful. The first part of the file consists of “meta information” (information that describes the material instead of the image material itself). For example, the 2nd line listed below determines 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 0 0 0 r I H D R 0000020 000 000 011 274 000 000 010 257 010 006 000 000 000 017 251 304 0 0 t 274 0 0 b 257 b 006 0 0 0 017 251 304 Extracting image information using exiftool Another tool for displaying image metadata is exiftool. In the example command below, we can

see extensive details on a png file.$exiftool coconuts.png ExifTool Variation Number: 12.42 File Call: coconuts.png Directory site:. File Size: 5.3 MB File Adjustment Date/Time: 2023:01:19 16:18:18 -05:00 File Gain Access To Date/Time: 2023:01:19 16:18:34 -05:00 File Inode Modification Date/Time: 2023:01:19 16:18:18 -05:00 File Permissions: -rw-r– r– Submit Type … Source

Leave a Reply

Your email address will not be published. Required fields are marked *