Convert HEIF Images to JPG or PNG on Linux (With Commands)

HEIF photos (those with the .HEIC file extension) can store image data more efficiently than JPG or PNG, which yields a smaller file size. But the glaring drawback is that HEIF doesn’t enjoy widespread support. If you have some HEIF photos that you need to convert to a different format, this can be done from the Linux command line.

In this tutorial, you’ll see how to convert HEIF images to JPG or PNG with Linux commands.

Install libheif on Linux

The heif-convert command is used to convert HEIF images to other formats. Use the appropriate command below to install the libheif package, containing the heif-convert utility, with your system’s package manager.

Ubuntu, Debian, and Linux Mint:

$ sudo apt install libheif-examples

Fedora:

$ sudo dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
$ sudo dnf install libheif

Arch Linux and Manjaro:

$ sudo pacman -S libheif

Convert HEIF images to JPG or PNG

1. Use the following syntax with the heif-convert command to convert a photo. Simply supply the name of the input file (the HEIC photo) followed by the name of the output file (the new JPG or PNG photo).

$ heif-convert image.HEIC new-image.jpg

or…

$ heif-convert image.HEIC new-image.png

2. The -q option will control the quality level of the output image. To keep your converted photos looking sharp, you should use the -q 100 setting to convert at maximum quality.

$ heif-convert -q 100 image.HEIC new-image.jpg

3. If you have a lot of HEIF photos to convert, you can use a Bash for loop to bulk convert hundreds or thousands of HEIC photos at once.

$ for f in *.HEIC; do heif-convert -q 100 $f $f.jpg; done

4. If you have HEIF files scattered throughout subdirectories, you can use the find command to traverse subdirectories and convert every .HEIC (or .heic) file that it finds.

$ find . -iname "*.heic" -exec heif-convert -q 100 {} {}.jpg \;

If our content helped you, please consider buying us a coffee. We appreciate your support!

Buy me a coffee donation button

Leave a Comment

Your email address will not be published. Required fields are marked *