Batch Converting JPEGs to HEICs
Why Convert to HEIC? #
HEICs are much smaller than JPEGs with no noticeable quality loss (at least as far as I can tell) so I use it to save a bit of storage space. I was able to get around a 75% reduction in file size for a set of images taken on a full frame camera (Sony a7IV).
Installing ImageMagick #
ImageMagick is an open-source CLI tool for image processing.
On macOS, install it with homebrew:
brew install imagemagick
On Ubuntu, use apt:
sudo apt install imagemagick
Converting Between Formats #
JPEG to HEIC #
magick convert input.jpg output.heic
HEIC to JPEG #
magick convert input.heic output.jpg
Batch conversion #
The mogrify
command is the batch version of the magick command.
These commands can take a while, depending on the size of your images and which formats you're converting from/to.
Convert a directory of JPEGs to HEICs #
mogrify -monitor -path OUTPUT_DIRECTORY -format heic *.jpg
The -path OUTPUT_DIRECTORY
is optional. By default, mogrify will place the new files in the current directory - overwriting any files with the same name.
Convert a directory of HEICs to JPEGs #
mogrify -monitor -path OUTPUT_DIRECTORY -format jpg *.heic
- Next: Data Cleaning with Awk