Monday, January 23, 2023
HomeNetworkingWorking with picture recordsdata on the Linux command line

Working with picture recordsdata on the Linux command line


Whereas one of the simplest ways to view or manipulate picture recordsdata on Linux is to open them in your desktop for viewing or manipulating with instruments like Gimp, there are fairly just a few methods to get necessary particulars on the command line.

Figuring out picture sort by file extension

Usually, picture recordsdata might be recognized on the command line by itemizing their names. Clearly “.jpg” represents a jpeg file, “.png” a conveyable community graphics file, “.gif” a graphics interchange format file, “.tiff” a tagged picture file and so forth.

$ ls -l photos 
-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

Almost all the time you may depend on file extensions precisely reporting the file sort, however there’s extra you are able to do with further instructions.

Figuring out photos with the file command

The file command can establish picture file varieties by extracting knowledge from the recordsdata themselves.

$ file Emmy.jpg
Emmy.jpg: JPEG picture knowledge, progressive, precision 8, 704x584, parts 3

The file under is clearly a jpg file regardless of its title. The output from the file command reviews this.

$ file camper.png
camper.png: JPEG picture knowledge, JFIF commonplace 1.01, decision (DPI), density 72x72, section size 16, Exif Commonplace: [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, parts 3

For many jpg recordsdata today, the file command will present much more particulars as within the examples above and under. This output consists of the file sort, decision particulars and fairly a little bit of details about the place the picture got here from and when it was taken.

$ file tulip_poplar.jpg
tulip_poplar.jpg: JPEG picture knowledge, Exif commonplace: [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, parts 3

As you may see from the output above, the tulip_poplar.jpg file was taken on Might 17, 2022, with a Samsung cellular phone,

Viewing picture particulars utilizing an octal dump

You may view some picture particulars utilizing the od -bc (octal dump) command. Nonetheless, wanting past the primary couple of traces may also show parts of the picture itself that received’t be useful. The primary a part of the file incorporates “meta info” (knowledge that describes the content material fairly than the picture content material itself). For instance, the second line under 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        r   I   H   D   R
0000020 000 000 011 274 000 000 010 257 010 006 000 000 000 017 251 304
             t 274      b 257  b 006       017 251 304

Extracting picture particulars utilizing exiftool

One other device for displaying picture metadata is exiftool. Within the instance command under, we are able to see intensive particulars on a png file.

$ exiftool coconuts.png
ExifTool Model Quantity         : 12.42
File Title                       : coconuts.png
Listing                       : .
File Measurement                       : 5.3 MB
File Modification Date/Time     : 2023:01:19 16:18:18-05:00
File Entry Date/Time           : 2023:01:19 16:18:34-05:00
File Inode Change Date/Time     : 2023:01:19 16:18:18-05:00
File Permissions                : -rw-r--r--
File Kind                       : PNG
File Kind Extension             : png
MIME Kind                       : picture/png
Picture Width                     : 2492
Picture Top                    : 2223
Bit Depth                       : 8
Shade Kind                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Pixels Per Unit X               : 11811
Pixels Per Unit Y               : 11811
Pixel Items                     : meters
Profile Title                    : Photoshop ICC profile
Warning                         : Set up Compress::Zlib to learn compressed info
ICC Profile                     : (Binary knowledge 2616 bytes, use -b choice to extract)
White Level X                   : 0.31269
White Level Y                   : 0.32899
Purple X                           : 0.63999
Purple Y                           : 0.33001
Inexperienced X                         : 0.3
Inexperienced Y                         : 0.6
Blue X                          : 0.15
Blue Y                          : 0.05999
Picture Measurement                      : 2492x2223
Megapixels                      : 5.5

The file under was taken in 2016. The main points saved inside the picture file itself are extremely intensive. It consists of not solely particulars about when the photograph was taken, but in addition the place it was taken. Word the GPS longitude and latitude measurements close to the underside.

$ exiftool myboy.jpg
ExifTool Model Quantity         : 12.42
File Title                       : myboy.jpg
Listing                       : .
File Measurement                       : 3.4 MB
File Modification Date/Time     : 2021:05:25 15:31:09-04:00
File Entry Date/Time           : 2023:01:01 15:44:38-05:00
File Inode Change Date/Time     : 2021:05:25 15:31:09-04:00
File Permissions                : -rw-r--r--
File Kind                       : JPEG
File Kind Extension             : jpg
MIME Kind                       : picture/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : samsung
Digital camera Mannequin Title               : SM-G935V
Orientation                     : Rotate 90 CW
X Decision                    : 72
Y Decision                    : 72
Decision Unit                 : inches
Software program                        : G935VVRU2APD2
Modify Date                     : 2016:06:16 13:54:56
Y Cb Cr Positioning             : Centered
Publicity Time                   : 1/245
F Quantity                        : 1.7
Publicity Program                : Program AE
ISO                             : 50
Exif Model                    : 0220
Date/Time Unique              : 2016:06:16 13:54:56
Create Date                     : 2016:06:16 13:54:56
Parts Configuration        : Y, Cb, Cr, -
Shutter Velocity Worth             : 1/245
Aperture Worth                  : 1.7
Brightness Worth                : 5.2
Publicity Compensation           : 0
Max Aperture Worth              : 1.7
Metering Mode                   : Heart-weighted common
Gentle Supply                    : Unknown
Flash                           : No Flash
Focal Size                    : 4.2 mm
Maker Word Model              : 0100
System Kind                     : Cell Telephone
Uncooked Information Byte Order             : Little-endian (Intel, II)
Uncooked Information CFA Sample            : Swap
Face Detect                     : Off
Person Remark                    : .
Flashpix Model                : 0100
Shade House                     : sRGB
Exif Picture Width                : 4032
Exif Picture Top               : 3024
Interoperability Index          : R98 - DCF primary file (sRGB)
Interoperability Model        : 0100
Sensing Methodology                  : One-chip coloration space
Scene Kind                      : Immediately photographed
Publicity Mode                   : Auto
White Steadiness                   : Auto
Focal Size In 35mm Format     : 26 mm
Scene Seize Kind              : Commonplace
Picture Distinctive ID                 : C12QSJB01SB
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Unknown (1.7)
GPS Time Stamp                  : 17:54:32
GPS Date Stamp                  : 2016:06:16
Compression                     : JPEG (old-style)
Thumbnail Offset                : 6142
Thumbnail Size                : 15400
Picture Width                     : 4032
Picture Top                    : 3024
Encoding Course of                : Baseline DCT, Huffman coding
Bits Per Pattern                 : 8
Shade Parts                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Time Stamp                      : 2016:06:16 13:54:56-04:00
Aperture                        : 1.7
Picture Measurement                      : 4032x3024
Megapixels                      : 12.2
Scale Issue To 35 mm Equal: 6.2
Shutter Velocity                   : 1/245
Thumbnail Picture                 : (Binary knowledge 15400 bytes, use -b choice to extract)
GPS Altitude                    : 0 m Above Sea Stage
GPS Date/Time                   : 2016:06:16 17:54:32Z
GPS Latitude                    : 39 deg 3' 8.04" N
GPS Longitude                   : 78 deg 22' 13.80" W
Circle Of Confusion             : 0.005 mm
Discipline Of View                   : 69.4 deg
Focal Size                    : 4.2 mm (35 mm equal: 26.0 mm)
GPS Place                    : 39 deg 3' 8.04" N, 78 deg 22' 13.80" W
Hyperfocal Distance             : 2.14 m
Gentle Worth                     : 10.5

In fact, I am now very inquisitive about that “Circle Of Confusion” area! Extra info on the exiftool output is obtainable in an earlier column, What do your pictures find out about you?

Viewing photos in ASCII

One other approach to take a look at photos on the command line is to make use of a device that shows picture content material in character format. In others phrases, the picture is displayed as characters and, for some instruments, each characters and colours to copy the picture. How properly this works will rely upon the picture itself and the device you employ. One such device is named img2txt. Had I included the colours within the picture under, you’d probably have the ability to acknowledge the penguin that’s waving at you.

$ img2txt penguin.png
                                                 @
                                               S8X
                                              S888
       8888@88XX8                           %@888@
    ;88percent88@@X888tS8                        S8888@X
   @SSpercenttS:8 8S8t8@:;                     ;@8888@8
  t8;.;%SXX@888@@88                    8S8888888@
  88:.;%888@88X: @@ %                 X88888888@X
 %X8;;88S8percentX88XS:.S  8              88@8888888@X
 X8Spercentt8 ;:t8.St% 8%.;@             88@8888888@@
 St888X8888@ 8888;888X8          X8X888888888X
;t:X8888888888:888888S@8        X@X88@88@8@@
  .S8888888@8@8@888tX% 888     8@88888888@
   %@X888@%88SX8X8%@:S88@888  8888888@88
 ;tSS@8 88.8S888:8@%XS%:88888@@8888@8
 SSSpercenttpercentSpercentX8 @888SX@X8percenttt88@X8@@8% .%
 8XXSpercenttpercenttX8:  8XX@88:@;;;tS8percentS;%S; :% 8
XX ;%%t%%SXS@8; XX  ;X;;;tt%%%%XS .:.%X.S         8
SX8@Spercent8Xpercent8XSpercentSpercentS8X8t;;;8%%%%%%tt;8%.:;;.%@.      888t
 X8SX@@%XX%%@Xtpercentt;;;;8%%%%%%%%tt;;%8 ::.:.:%      8888

Wrap-up

Whereas viewing picture recordsdata on the command line will not be prone to generate deep emotions of nostalgia, you may extract quite a lot of fascinating picture particulars that inform you in regards to the sorts of photos, when and the place pictures had been taken, and how much machine was used to take the pictures.

Copyright © 2023 IDG Communications, Inc.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments