HEIC Woes

The new-ish High Efficiency Image File Format has a lot of advantages over older formats but compatibility is currently not one of them.

Apple switched to .heic as the default image format of the iOS Camera app somewhere in 2017 and since then support has lagged. Even in Apple’s own iCloud…

iCloud HEIC Error

Windows requires you to download additional codecs to view them locally.

Quite frankly, for me the advantages aren’t currently worth the incompatibilities I’ve run into with HEIC. So I switched back to Camera.app saving images in JPG again: Settings -> Camera -> Formats -> Most Compatible

…But not before I unknowingly took a few hundred photos in HEIC.

Conversion it is.

Google will return a slew of web-based image conversion sites that purport to support converting HEIC to JPG and I’m sure they work fine. But I don’t want to trust my photo library to some random website. So I opted to write a PowerShell script to convert an entire directory of them locally. Most likely using the same tool those websites are using to convert them remotely anyway, ImageMagick.

ImageMagick is an incredibly robust image manipulation tool used by web apps to convert, edit, and resize images on the fly.

It also runs on just about anything so I was able to easily install it on Windows for use with my PowerShell script.

[CmdletBinding()]
param (
    [parameter(mandatory = $true, position = 1)]
    [string]$convertFromDir
)

$files = Get-ChildItem -Path $convertFromDir -Filter *.heic

$convertedDir = New-Item -Name HEIC2JPG -Path $convertFromDir -ItemType directory

foreach($file in $files) {
    $newJPGFile = $file -Replace '\.heic$', '.jpg'
    magick $convertFromDir\$file $convertedDir\$newJPGFile
    Write-Host "Converted $file to HEIC2JPG\$newJPGFile"
}

The script takes one argument, provide a directory path containing .heic files you’d like to convert to .jpg. A new directory called HEIC2JPG will be created within the supplied directory where your converted JPGs will be placed.

Make sure you download and install ImageMagick 7+ before you try running the script.

For example: ./Convert-HEIC2JPG.ps1 c:\users\ethan\downloads\photos\

Example output

Written on May 1, 2021