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.jpgReduce 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.pdfAssemble images vertically:
1
$ convert img1.jpg img2.jpg img3.jpg -append big.jpgAssemble images horizontally:
1
$ convert img1.jpg img2.jpg img3.jpg +append big.jpg
Cropping
Remove all whitespace (or any solid-color) surrounding the original.png image:
1
$ convert ./original.png -trim ./trimmed.pngAdd a 5% white border around the image:
1
$ convert ./original.png -bordercolor White -border 5%x5% ./original-with-border.pngSame 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 -targaSame 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.MOV2Audio Channels : 23Compressor Version : CanonAVC00024Camera Model Name : Canon EOS 7D5Firmware Version : Firmware Version 2.0.36Image Size : 1920x10807Megapixels : 2.18Avg Bitrate : 47.5 Mbps9(...)10Same as above but print the canonical ID of each field:
1
$ exiftool -short ./MVI_4441.MOV2AudioChannels : 23CompressorVersion : CanonAVC00024Model : Canon EOS 7D5FirmwareVersion : Firmware Version 2.0.36ImageSize : 1920x10807Megapixels : 2.18AvgBitrate : 47.5 Mbps9(...)10Print all metadata, with fields grouped by their family:
1
$ exiftool -groupHeadings MVI_4586.MOV2---- ExifTool ----3ExifTool Version Number : 12.604---- File ----5File Name : MVI_4586.MOV6File Type : MOV7File Type Extension : mov8MIME Type : video/quicktime9---- QuickTime ----10Major Brand : Apple QuickTime (.MOV/QT)11Minor Version : 2007.9.012Media Data Offset : 3213Movie Header Version : 014(...)15Show all date fields with their canonical IDs, grouped by family:
1
$ exiftool -groupNames -short -'*Date' MVI_4586.MOV2[File] FileModifyDate : 2023:06:03 17:14:28+04:003[File] FileAccessDate : 2023:06:03 21:36:26+04:004[File] FileInodeChangeDate : 2023:06:03 18:55:28+04:005[QuickTime] CreateDate : 2015:09:26 14:44:106[QuickTime] ModifyDate : 2015:09:26 14:44:107[QuickTime] TrackCreateDate : 2015:09:26 14:44:108[QuickTime] TrackModifyDate : 2015:09:26 14:44:109[QuickTime] MediaCreateDate : 2015:09:26 14:44:1010[QuickTime] MediaModifyDate : 2015:09:26 14:44:10Copy the CreateDate field of the QuickTime family from a MVI_4586.MOV file to MVI_4586.mp4:
1
$ exiftool -tagsfromfile MVI_4586.MOV "-QuickTime:CreateDate" MVI_4586.mp4Same as above but for all date fields:
1
$ exiftool -tagsfromfile MVI_4586.MOV "-QuickTime:*Date" MVI_4586.mp4Transfer all *Date fields from all .MOV files of the current ./ directory to their corresponding .mp4 files:
1
$ exiftool -tagsfromfile %f.MOV "-QuickTime:*Date" -ext mp4 ./Remove all metadata of a JPEG file:
1
$ exiftool -all= image.jpgPrefix 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"; doneRemove 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 - NYE album to the current folder, and download from iCloud the missing ones:
1
$ osxphotos export ./ --album "2012-12-32 - NYE" --download-missing --only-moviesSame as above but only for videos shot with a Canon camera and encoded with the CanonAVC0002 codec:
1
$ osxphotos export ./ --album "2012-12-32 - NYE" --download-missing --only-movies --exif CompressorVersion 'CanonAVC0002'Export all videos from the Yearly archives/2014 subfolder while keeping the same folder structure:
1
$ osxphotos export ./ --regex "Yearly archives/2014" "{folder_album}" --download-missing --only-movies --directory "{folder_album}"