Running Linux and working in Cloud and HPC it is common for me to be stumped when problems appear. Indeed that is where the fun is. However, after receiving a link to download some photos from a recent even, I was shocked to see the images were in .heicformat.1 I have never heard of this and was shocked that something as simple as an image file could not be opened easily on my fancy, sleek, XPS-13.

So below is how I converted these images into .jpg.

First install libheif-examples from the terminal.

sudo apt-get update
sudo apt-get install libheif-examples

You can then run the below command to convert an input into and output jpg. Obviously change the file names in the below example to reflect. 2

heif-convert input.heic output.jpg

I’m sure, however, that you don’t have just one file - you might have a folder full of images. In that case you can create a script in the same folder as your images

touch  convert_all_heif_to_jpg.sh

and paste: 3

#!/bin/bash

# Directory containing HEIF files
input_dir="."

# Loop through all HEIF files in the directory
for file in "$input_dir"/*.heic; do # Check that this is the right extention! 
    # Check if any HEIF files exist
    if [ -e "$file" ]; then
        # Get the base name of the file (without extension)
        base_name=$(basename "$file" .heif)

        # Convert HEIF to JPEG
        heif-convert "$file" "$input_dir/$base_name.jpg"

        # Optional: Remove additional files created by heif-convert
        find "$input_dir" -maxdepth 1 -type f ! -name "$base_name.heif" ! -name "$base_name.jpg" -name "$base_name*" -exec rm -f {} +
    fi
done

echo "Conversion completed."

Make the script executable with the below:

chmod +x convert_all_heif_to_jpg.sh

and run it!

./convert_all_heif_to_jpg.sh

That should do it! Enjoy your photos!


  1. I’m no expert but heic and heif are similar formats - you will see both used interchangeably here. ↩︎

  2. No idea why this command creates a bunch of extra files, not just a .jpg, for single files this is not a problem and you can just delete them. For the longer script I’ve added the ability to delete all but the wanted .jpeg. ↩︎

  3. Please note, this script can convert .heif files to, just change the change line 5 to reflect which format you have. In this instance it is .heic not .heif. ↩︎