Command Line Image Tools
Jump to navigation
Jump to search
Preview[edit]
To preview an image file from the command line:
$ qlmanage -p filename.jpg
Extracting metadata[edit]
Using ImageMagick[edit]
$ convert filename.jpg -print "%w x %h\n" /dev/null
sips[edit]
sips is a command line tool installed by default on Mac OS.
Editing images[edit]
It can be used to flip, crop, and resize image files.
# changes aspect ratio $ sips -z [height] [width] path/to/image.jpg # maintains aspect ratio; width and height cannot exceed value; N.B. uppercase "Z" $ sips -Z [heightwidth] path/to/image.jpg # rotate image sips -r 90 path/to/file.jpg --out rotatedfile.jpg
Inspecting metadata[edit]
sips supports NEF and PSD file format along with the more command image formats.
$ sips -g all path/file.extension pixelWidth: 1920 pixelHeight: 1080 typeIdentifier: public.jpeg format: jpeg formatOptions: default dpiWidth: 72.000 dpiHeight: 72.000 samplesPerPixel: 3 bitsPerSample: 8 hasAlpha: no space: RGB profile: sRGB IEC61966-2.1
Converting file formats[edit]
$ sips -s format jpeg -s formatOptions 80 "source_image.tiff" --out "converted_image.jpg"
formatOptions controls the JPEG compression of the destination image.
exiftool[edit]
Inspecting metadata[edit]
Applying the following command to a Photoshop file results in a lot of overly verbose information.
$ exiftool paris-texas-00_05_34-00001.jpg ExifTool Version Number : 12.49 File Name : paris-texas-00_05_34-00001.jpg Directory : . File Size : 310 kB File Modification Date/Time : 2023:04:07 09:28:48-07:00 File Access Date/Time : 2023:04:07 11:13:20-07:00 File Inode Change Date/Time : 2023:04:07 09:28:48-07:00 File Permissions : -rw-r--r-- File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg JFIF Version : 1.01 Resolution Unit : None X Resolution : 1 Y Resolution : 1 Image Width : 1920 Image Height : 1080 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Image Size : 1920x1080 Megapixels : 2.1
Editing images[edit]
exiftool can also edit images, e.g. |rotating NEF files.
ffmpeg[edit]
ffmpeg is useful for converting image files to different formats.