Stanley Solutions Blog

engineering and creativity - all under one hat

Quick-n-Simple Photo Converter (for HEIC format)


I end up taking lots of pictures. Maybe not as many as some folks, but I do take a lot... Pretty much all of those pictures are taken with my iPhone. As such, they're all in the .heic (high efficiency image) format. Now, that's neat and all, but those images are harder to embed in all the places I want to put them. Thus, I'm stuck back-converting them to PNG format.

Like any good programmer, I went right to Google to do a little "lookin' around" to find a way to do this with locally on a Linux machine.

Didn't take long to find plenty of articles recommending heif-convert, which can be installed with the following command:

sudo apt install libheif-examples

GREAT!

... but ...

It's a touch too long for my impatient fingers, and I don't want to run that same command over, and over, and over, and over, and over again...

Time for a script!

I decided to make a simple little script to find all of the *.heic photos in the specified directory, and run the conversion required...

#!/usr/bin/bash
# Simple HEIC Conversion Utility (so Joe doesn't need to remember)
for file in $1/*.HEIC
do
    echo "Converting: $file"
    heif-convert "$file" "${file%.*}.png"
    rm $file
done

photo-convert script

This really made for a nice, handy little script for my photo conversion needs. Maybe you'll find it helpful, too!