Help with heic files

Discussion in 'all things UNIX' started by fblais, Apr 24, 2025.

  1. fblais

    fblais Registered Member

    Joined:
    Jul 31, 2008
    Posts:
    1,371
    Location:
    Québec, Canada
    Hi.
    I have an heic image file which I know has 16 images inside.
    I want to "extract" the content into individual files in jpg format, in some batch processing.
    I'm trying with imagemagick on the command-line but only get the first image.
    Can someone please tell me the correct command-line syntax?

    example of the last thing I tried:
    convert *.heic[0-15] *.jpg

    Thanks!
     
  2. FanJ

    FanJ Updates Team

    Joined:
    Feb 9, 2002
    Posts:
    4,953
  3. fblais

    fblais Registered Member

    Joined:
    Jul 31, 2008
    Posts:
    1,371
    Location:
    Québec, Canada
    Thanks, I'll check that one!
     
  4. fblais

    fblais Registered Member

    Joined:
    Jul 31, 2008
    Posts:
    1,371
    Location:
    Québec, Canada
    This was not helpful.
    However, this worked:

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

    I'm not sure if heif-convert is part of Imagemagick though.
    It probably comes from package libheif-examples instead.
     
  5. nicolaasjan

    nicolaasjan Registered Member

    Joined:
    Sep 23, 2018
    Posts:
    990
    Location:
    The Netherlands
    My script is a bit different:
    Code:
    for i in *.heic; do heif-convert -q 100 "${i}" "${i%.heic}.jpg"; done
    (less compression in the jpg)
     
  6. fblais

    fblais Registered Member

    Joined:
    Jul 31, 2008
    Posts:
    1,371
    Location:
    Québec, Canada
  7. nicolaasjan

    nicolaasjan Registered Member

    Joined:
    Sep 23, 2018
    Posts:
    990
    Location:
    The Netherlands
    And for Windows (bat file):
    Code:
    @echo off
    for %%f in (*.heic) do (
        echo Converting %%f to %%~nf.jpg
        heif-convert -q 100 "%%f" "%%~nf.jpg"
    )
    Ensure heif-convert.exe is installed and in the system's PATH.

    I have no idea where to get a recent compiled executable for Windows. Maybe compile from source?
    There is a rather old one here.

    I do know that IrfanView with plugins can batch convert them, but you also have to install the necessary “HEIF Image Extensions” and “HEVC Video Extensions” MS Store Apps.
    The HEVC extension is not free any more, except when you go to the store via this direct link:
    Code:
    ms-windows-store://pdp/?ProductId=9n4wgh0z6vhq
    .
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.