Productivity Tech

Linux: How To Convert HEIC Files to JPG or PNG

As some of you might know, iPhone has its own picture file format. The HEIC(High-Efficiency Image Container) format. it doesn’t always work when you want to upload it to many websites. There are some websites out there that can convert it for you. It might be okay for some photos that you don’t care about. But for some family photos, you might not want to share them on some random websites.

I found that on Linux, you can simply install a command-line tool called heif-convert. To use it, simply install the libheif-examples command-line. heif-convert just comes with it for free. To install, run the following command:

sudo apt-get install libheif-examples

You can easily convert your HEIC file with the following command:

heif-convert [original-file-name] [file-name-with-jpg-or-png-extension]

For example, if you have a file called IMG_1234.HEIC and want to convert it to IMG_1234.jpg, you can simply run:

heif-convert IMG_1234.HEIC IMG_1234.jpg

Easy, isn’t it? This command can only convert 1 file at a time, which can be annoying when you need to convert multiple files. If you’re lucky, all of the files you drag from the iPhone will have lowercase extension “heic”. You can run this script to convert them:

for file in *.heic; do heif-convert $file ${file/%.heic/.jpg}; done

Sometimes, some files are in lowercase and some come with uppercase. There are many ways to deal with this issue. You can rename all the files to lowercase and then run the above command, you can write a program that reads all the files and then run the heif-convert command.

I took the route to learn about how to do that with a bash script. My script will read all the files that contain “.heic” or “.HEIC” in the filename. Then convert them into jpg format with the heif-convert command.

I created a GitHub repository for any handy command in the future. You can download the executable from here. To run it:


If my note helped, please consider buying me a coffee😁.



2 replies on “Linux: How To Convert HEIC Files to JPG or PNG”

Hi Lok,

Thanks for the post. Has helped me out with the wife’s photos.
As you took the time to learn to write a bash I thought you might be interested in learning about xargs. You can do what your bash script does with something like:
ls *.HEIC | xargs -P4 -I% bash -c ‘heif-convert $1 ${1/.HEIC/.jpg}’ — %

The main advantage of this is the -P4 option tells xargs to run 4 of these in parallel. I have an 8 thread laptop so running 4 in parallel leaves 4 for doing other work.

The ${file/.heic/.jpg} syntax is not something I have seen before. Very neat.

Thanks again for your work.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.