Converting from HEIC to JPEG on OS X

Apple has been slowly moving from the trusty JPEG standard to HEIC, and the rest of the world has been slow to actually catch up to the newer format. While my phone and Mac do just fine, the only real early adopter I’ve seen that supports HEIC has been Dropbox.

While uploading photos to on online service for prints, all of the photos shot on my phone were rejected as “unsupported format”. There were over 300 photos I wanted to add to the catalog, and there was absolutely NO WAY I was going to download some pay-to-play utility, or upload them to an online “free” conversion service.

The good news is, if you are running OS X, you have all you need. You just need to do it in terminal and run this command in the directory where your HEIC files are stored.

for file in $(find ./ -name "*.HEIC" -print) ; \ 
do sips -s format jpeg $file --out "${file%.*}.JPG" ; \
touch -r $file "${file%.*}.JPG" ; \
done

The above bashism will use ‘find’ to go through the current directory and all directories underneath it and look for files with the HEIC extension. When it finds one, it creates a new JPEG version of the file and then sets the timestamp of the JPEG version to the same as the original HEIC file.

This also works if you need to convert a large number of RAW image files from say, a Nikon camera. Just replace the “HEIC” to “RAW” and it will convert RAW image files.

Like this:

for file in $(find ./ -name "*.RAW" -print) ; \ 
do sips -s format jpeg $file --out "${file%.*}.JPG" ; \
touch -r $file "${file%.*}.JPG" ; \
done

Does it work the other way, taking JPEG back to HEIC? Nope.

The same kind of bashism can also be used to remove EXIF data from the JPEG images.

for file in $(ls -1 *.JPEG) ; \
do exiftool -all= $file ; \
done