Archive for September 2nd, 2019

Bulk Convert jpg to HEIC (with metadata!)

Want to bulk-convert jpg files to the more space-efficient HEIC format, and preserve your metadata while you’re at it?

Here’s a few commands to do just that.

This will assume all images in the current directory have ‘.jpg’ extensions, and may have an ‘.XMP’ sidecar file with metadata in it. Most photo libraries, including macOS Photos, have an option to export files with metadata in an XMP sidecar file. Doing this is highly recommended, as it will pull in metadata from the sidecar file that may not be embedded in the original image.

These bash one-liners were run using bash 3.2.57. These also require the latest (as of this writing) ExifTool and ImageMagick installed and on your path. If you’re using macOS, ExifTool and ImageMagick can be installed using Homebrew with the following commands:

brew install exiftool
brew install imagemagick

Once you have those, you’re ready to go.

First, convert all the files to HEIC:

for x in *.jpg; do echo "$x"; magick "$x" "${x%.jpg}.HEIC"; done 

Next, import the metadata from each source image:

for x in *.jpg; do echo "$x"; exiftool -overwrite_original -tagsFromFile "$x" -all:all "${x%.jpg}.HEIC"; done

Last, import any additional metadata from XMP sidecar files, if they exist:

for x in *.jpg; do echo "$x"; exiftool -overwrite_original -tagsFromFile "${x%.jpg}.XMP" -all:all "${x%.jpg}.HEIC"; done

That’s it!


, , , , , ,

Leave a comment