Well, now.

I recently found myself in the position of needing to convert a chunk of my photos (OVER! NINE! THOUSAND!) that were stored in the Mac Photos app from HEIC format into JPG.  All so I could back them up to my Flickr account (which doesn't deal well with HEIC.  Come on, guys. Seriously?)

I was about to give up on the idea of it being simple - or automatable - and start looking at how to install ImageMagick on my Mac, when I came across this amazing and wonderful bit of advice that saved my bacon.
Use sips to quickly, easily—and freely—convert image files
Quite often, I find myself with a number of images (screenshots, typically) that I’ll want to convert from one format to another. If you search the Mac App Store, there are probably 300 apps that will let you do this; many are probably free. You could also use Automator, which has some good image conversion abilities, but can’t (for example) specify the quality of a JPEG conversion.
But the best way I’ve ever found is to use a tool that’s been included with every copy of macOS since the release of Mac OS X 10.3 (Panther) in October of 2003: A command line tool called sips. Yes, it requires using Terminal, but it’s quite easy to use. sips can modify one file, or any number of files, converting from one format to another. You can also use sips to resize images, rotate images, and more.
Here's what worked like a peach for me:

  # mkdir -p ~/photo_tmp

  # cd ~/Pictures/Photos\ Library.photoslibrary

  # for f in $(find . -name '*.HEIC'); do \
      fname="${file##*/}" ; \
      sips -s format jpeg -s formatOptions best \
        "${f}" --out "~/photo_tmp/${fname%HEIC}JPG" ; \
    done

Following that, open the Photos app and import the generated files.  While they will all show as imported today (whenever you do the actual import), Photos is smart enough to pick up the EXIF data in the images and put them in their proper location, chronologically speaking.

I ended up with doubled files as a result - ex, IMG_0001.HEIC and IMG_0001.JPG - but that's fine for me.  I can go back and clean up the HEIC files later if I wan to, and in the meantime, I have what I really wanted - JPG versions of those image files that can be uploaded to Flickr.


No comments: