Batch Convert HEIC to JPG in Linux

You may also like...

16 Responses

  1. David says:

    When I run “sudo apt-get install libheif-examples” I get the following output…

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package libheif-examples

    Any idea of why or a work around? Thanks!

  2. redoudou says:

    Thank you very much work like magic !

  3. Ivan says:

    sudo add-apt-repository ppa:strukturag/libheif
    sudo apt-get update

  4. Jojo says:

    when i try to do output to .jpeg it throws error unknow file type 13, is it only support jpg output?

  5. Milan Karunarathne says:

    Thanks very much … !!!

  6. LT says:

    This was really good – exactly what I was looking for so thanks for that!

    if you don’t want the output file to have the .heic.jpg file extension after conversion you can use the following to strip it off and replace it with .jpg

    img=$(echo $f | sed “s/\.heif$/\.jpg/”); heif-convert $f $img

    if you wanted to do it all with a one-liner you can use: find . -name “*.heif” -exec bash -c ‘img=$(echo $1 | sed “s/\.heif$/\.jpg/”); heif-convert $1 $img’ _ {} 2>&1 \;

    basically here the results of the find command are passed in as arguments to the bash script. the _ is the $0 arg and the {} is the filename which ends up as $1 within the bash command.

  7. Francis says:

    it start to convert but every file has that note:

    “Not a *.jpg / *.png / *.mp4 / *.avi! IMG_0001.HEIC”

    …in the folder, the files are also .HEIC-format… did i missed something? Thanks for help!

  8. sysdef says:

    what is wrong with `mogrify -format jpg *.heic` ?

  9. David says:

    This was incredibly helpful and easy to follow. Thanks so much for the information!

  10. Andy says:

    Is there a easy way to edit the script, so that it can be stored in an upper directory, so that all files within the subdirectories are converted (something like *.* I tried it without success)

  11. Simon says:

    Awesome, worked flawlessly. Thank you

  12. obenomar says:

    Good to show me the path for making this automated. Here is a slightly improved version of the converting script, that checks whether the jpg file exist and skip the conversion if this is the case.
    Very useful if you have new pictures arriving in your archive in HEIC format…
    #!/bin/bash
    for f in $(find -name “*.HEIC”)
    do
    echo “Working on file $f”
    FILE=$f.jpg
    if [ -f “$FILE” ]; then
    echo “$f already exist in jpg: $FILE. No conversion.”
    else
    heif-convert $f $f.jpg
    fi
    done

  13. Eric Järpe says:

    Excellent! Thanks!!

  14. sardeenz says:

    thanks. great help

  1. January 16, 2020

    […] Source: Stuff Jason Does […]

Leave a Reply to Eric Järpe Cancel reply

%d bloggers like this: