Conversion
-
Convert several files from a format to another:
1$ convert img_*.bmp img_%04d.png
Resize
-
Resize images of the current folder to progressive jpeg. Resized images will not be greater than 600x600, but the aspect ratio will be respected:
1$ convert -resize 600x600 -sharpen 1 -interlace Line ./* ./pict%04d.jpg
-
Reduce size of a PDF by limiting its images to 1000 pixels and convert its color-space to grayscale:
1$ convert -resize 1000x1000 -type Grayscale ./big.pdf ./smaller.pdf
-
Assemble images vertically:
1$ convert img1.jpg img2.jpg img3.jpg -append big.jpg
-
Assemble images horizontally:
1$ convert img1.jpg img2.jpg img3.jpg +append big.jpg
Cropping
-
Remove all whitespace (or any solid-color) surrounding the
original.pngimage:1$ convert ./original.png -trim ./trimmed.png
-
Add a 5% white border around the image:
1$ convert ./original.png -bordercolor White -border 5%x5% ./original-with-border.png
-
Same as above but with a deep black 5% border on the side and a total image height 3x times taller as the original:
1$ convert ./original.png -bordercolor '#1a1a1a' -border 5%x100% ./original-with-border.png
Optimization
-
Massive in-place optimization of all PNG images available in sub-directories:
1$ find ./ -iname "*.png" -exec pngcrush "{}" "{}.crushed" \; -exec mv "{}.crushed" "{}" \;
-
Same as above, but remove all known chunks, those encoding color profiles, gamma and text, and only keeps transparency chunks:
1$ find ./ -iname "*.png" -exec pngcrush -rem alla "{}" "{}.crushed" \; -exec mv "{}.crushed" "{}" \;
-
Lossless optimization of JPEG files:
1$ find . -iname "*.jpg" -exec jpegtran -optimize -outfile "{}.optimized.jpeg" "{}" \;
-
Convert a PNG file to an optimized JPEG:
1$ convert ./original.png TGA:- | cjpeg -optimize -progressive -quality 80 -outfile compressed-image.jpeg -targa
-
Same as above but as a loop for all PNG files in current folder:
1$ for f in *.png; do convert "$f" TGA:- | cjpeg -optimize -progressive -quality 80 -outfile "$f.jpeg" -targa; done
Metadata
-
Print all metadata of a video file:
1$ exiftool ./MVI_4441.MOV 2Audio Channels : 2 3Compressor Version : CanonAVC0002 4Camera Model Name : Canon EOS 7D 5Firmware Version : Firmware Version 2.0.3 6Image Size : 1920x1080 7Megapixels : 2.1 8Avg Bitrate : 47.5 Mbps 9(...)
-
Same as above but print the canonical ID of each field:
1$ exiftool -short ./MVI_4441.MOV 2AudioChannels : 2 3CompressorVersion : CanonAVC0002 4Model : Canon EOS 7D 5FirmwareVersion : Firmware Version 2.0.3 6ImageSize : 1920x1080 7Megapixels : 2.1 8AvgBitrate : 47.5 Mbps 9(...)
-
Print all metadata, with fields grouped by their family:
1$ exiftool -groupHeadings MVI_4586.MOV 2---- ExifTool ---- 3ExifTool Version Number : 12.60 4---- File ---- 5File Name : MVI_4586.MOV 6File Type : MOV 7File Type Extension : mov 8MIME Type : video/quicktime 9---- QuickTime ---- 10Major Brand : Apple QuickTime (.MOV/QT) 11Minor Version : 2007.9.0 12Media Data Offset : 32 13Movie Header Version : 0 14(...)
-
Show all date fields with their canonical IDs, grouped by family:
1$ exiftool -groupNames -short -'*Date' MVI_4586.MOV 2[File] FileModifyDate : 2023:06:03 17:14:28+04:00 3[File] FileAccessDate : 2023:06:03 21:36:26+04:00 4[File] FileInodeChangeDate : 2023:06:03 18:55:28+04:00 5[QuickTime] CreateDate : 2015:09:26 14:44:10 6[QuickTime] ModifyDate : 2015:09:26 14:44:10 7[QuickTime] TrackCreateDate : 2015:09:26 14:44:10 8[QuickTime] TrackModifyDate : 2015:09:26 14:44:10 9[QuickTime] MediaCreateDate : 2015:09:26 14:44:10 10[QuickTime] MediaModifyDate : 2015:09:26 14:44:10
-
Copy the
CreateDatefield of theQuickTimefamily from aMVI_4586.MOVfile toMVI_4586.mp4:1$ exiftool -tagsfromfile MVI_4586.MOV "-QuickTime:CreateDate" MVI_4586.mp4
-
Same as above but for all date fields:
1$ exiftool -tagsfromfile MVI_4586.MOV "-QuickTime:*Date" MVI_4586.mp4
-
Transfer all
*Datefields from all.MOVfiles of the current./directory to their corresponding.mp4files:1$ exiftool -tagsfromfile %f.MOV "-QuickTime:*Date" -ext mp4 ./
-
Remove all metadata of a JPEG file:
1$ exiftool -all= image.jpg
-
Prefix all JPEG filename with their EXIF date:
1$ for i in *.jpg; do exiv2 -v -r '%Y%m%d_%H%M%S_:basename:' rename "$i"; done
-
Remove recursively (and in-place) the color profile and comments embedded in all PNG images:
1$ mogrify -verbose -monitor -strip ./*.png
macOS’s Photos.app &
osxphotos
-
Export all videos from the
2012-12-32 - NYEalbum to the current folder, and download from iCloud the missing ones:1$ osxphotos export ./ --album "2012-12-32 - NYE" --download-missing --only-movies
-
Same as above but only for videos shot with a Canon camera and encoded with the
CanonAVC0002codec:1$ osxphotos export ./ --album "2012-12-32 - NYE" --download-missing --only-movies --exif CompressorVersion 'CanonAVC0002'
-
Export all videos from the
Yearly archives/2014subfolder while keeping the same folder structure:1$ osxphotos export ./ --regex "Yearly archives/2014" "{folder_album}" --download-missing --only-movies --directory "{folder_album}"