Command Line Image Tools: Difference between revisions
Jump to navigation
Jump to search
Tag: wikieditor |
No edit summary Tag: wikieditor |
||
| (8 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Preview == | |||
To preview an image file from the command line: | |||
<syntaxhighlight lang="bash"> | |||
$ qlmanage -p filename.jpg | |||
</syntaxhighlight> | |||
== Extracting metadata == | |||
=== Using ImageMagick === | |||
<syntaxhighlight lang="bash"> | |||
$ convert filename.jpg -print "%w x %h\n" /dev/null | |||
</syntaxhighlight> | |||
== sips == | == sips == | ||
`sips` is a command line tool installed by default on Mac OS. | `sips` is a command line tool installed by default on Mac OS. | ||
It can be used to flip and resize image files. | === Editing images === | ||
It can be used to flip, crop, and resize image files. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# changes aspect ratio | # changes aspect ratio | ||
$ sips -z [height] [width] path/to/image.jpg | $ sips -z [height] [width] path/to/image.jpg | ||
# maintains aspect ratio | # maintains aspect ratio; width and height cannot exceed value; N.B. uppercase "Z" | ||
$ sips - | $ sips -Z [heightwidth] path/to/image.jpg | ||
# rotate image | # rotate image | ||
sips -r 90 path/to/file.jpg --out rotatedfile.jpg | sips -r 90 path/to/file.jpg --out rotatedfile.jpg | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Inspecting metadata === | |||
`sips` supports NEF and PSD file format along with the more command image formats. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 32: | Line 52: | ||
profile: sRGB IEC61966-2.1 | profile: sRGB IEC61966-2.1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Converting file formats === | |||
<syntaxhighlight lang="bash"> | |||
$ sips -s format jpeg -s formatOptions 80 "source_image.tiff" --out "converted_image.jpg" | |||
</syntaxhighlight> | |||
`formatOptions` controls the JPEG compression of the destination image. | |||
== exiftool == | == exiftool == | ||
=== Inspecting metadata === | |||
Applying the following command to a Photoshop file results in a lot of overly verbose information. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 64: | Line 94: | ||
Megapixels : 2.1 | Megapixels : 2.1 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Editing images === | |||
`exiftool` can also edit images, e.g. [[Change Orientation of NEF Files in EXIF Data||rotating NEF files]]. | |||
== ffmpeg == | == ffmpeg == | ||
| Line 73: | Line 107: | ||
* [[Batch Converting Image Files]] | * [[Batch Converting Image Files]] | ||
* [[Change Orientation of NEF Files in EXIF Data]] | * [[Change Orientation of NEF Files in EXIF Data]] | ||
[[Category:Command Line]][[Category:Bash]][[Category:Zsh]] | |||
Latest revision as of 16:51, 20 September 2023
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.