How to extract multiple images contained in HEIC file format?

Hi Everyone !!
I have multiple heif files which contains lots of images inside of them. I want to extract all of those pictures in my system but sadly heif just shows one picture inside.

While searching for solution I stumbled across these stackoverflow threads which gave me little idea but not a whole lot of to find out the solution. I had suggested ffmpeg but I couldn’t do it via that method since heif is still not supported in ffmpeg.

Can someone help me find out the soultion.
I want to extract images off heif files !!

Finger cross this thread won’t be left unanswered

Yours,

Hello @Unbeknownst :wink:

Did you try heif-convert on the terminal? It can convert it into jpg, png, and y4m. Should be available when libheif is installed.

Btw…

Heif/heic has more than one picture inside? So it is similar to a gif? Anyway… it is a picture compressed with the video compression h.265. So no doubt there can be more than one picture.

2 Likes

imagemagick can do that from terminal:

magick convert *.heic out.png

Depending on the number of layers the .heic file has, you will have out-0.png out-1.png and so on … You can also use .jpg format too instead of .png

3 Likes

Hello @megavolt So sorry for the late reply !!
I tried this heif-convert on terminal but it keeps on giving corrupted images to me.


image

I even tried multiple parameters like with-aux with-xmp without knowing what it means but it kept dumping error image.
To be clear, I have a heic file with multiple images inside of them. I want to extract all of those images in png form. The heic file isn’t compressed or is neither a gif. A heic file is a High Efficiency Image File Format that has really low file size with really hd pictures inside of them.
@bogdancovaciu the method you gave me resulted out the same image as GIMP export feature which is really low in quality and not giving me lots of images inside of that heic file. In my macbook it was able to convert this heic file to 500 mb of picture but in linux it couldn’t. Macbook was able to showme all of those images but linux just shows the thumbnail and upon converting it converts this into thumbnail. Macbook has multiple images inside of those pngs which I have but again in linux it shows nothing but one picture. I hope I am not confusing you guys.
image

I really thank you guys for helping me out. But it seems like I am on a deadend. Any sort of help is appreciated if you guys have idea about it.
Hope you have a wonderful day :slight_smile:

@Unbeknownst

Can you tell if that is a image sequence or a image collection? Maybe share an example so that we can test your image? I never used heif or heic, since I don’t use Apple products, and all samples on the internet have only one image. Thanks.

1 Like

I was interested because I may need to do that as well in the near future.

The image format is just a container that can hold different things.
This here suggests that inside that image could be a sequence of pictures - like frames in a video.
and ffmpeg could be used to extract the individual frames.

I don’t have such pictures at the moment - but I have used ffmpeg to extract frames from video,
a long time ago, need to reconstruct the command from scratch, but it should be fairly easy.

https://stackoverflow.com/questions/56194892/how-to-extract-multiple-images-contained-in-heic-file-format

I noticed that you tried to use
heif-convert
but you used a .png file as the input
(and crashed the program - perhaps because of it)

I’d have expected you to use the .heif file.

I don’t know what to call it though. It is a 500 mb of file which has multiple images inside of it. I don’t have my macbook right now and don’t really have any example on the internet I can show it to you. I will send those pictures asap.

Hello @Nachlese Thanks a lot but I also tried this one before but have been disappointed with errors.
The thread said: HEIC is just a container and in an image-burst-based HEIC, there is an embedded hevc/hvc1 video stream. (actually there are multiple streams) and you can extract these to “frames”

I am not that familiar with this frame extraction method from ffmpeg. Can you give me the correct command for it ?

Edit for your

: https://forum.manjaro.org/uploads/default/original/3X/9/7/979f66d0193aea2861e239cabba0b08556c1af20.png
As you can see I have used heic file as input and png as output as required.

Ok well I created an image myself:

 heif-enc -o pic.heic pic1.jpg pic2.jpg

As you see it contains 2 pictures:

$ identify pic.heic                                                                                                                                                  ✔
pic.heic[0] HEIC 4800x2700 4800x2700+0+0 8-bit sRGB 58487B 0.000u 0:00.000
pic.heic[1] HEIC 1920x1080 1920x1080+0+0 8-bit sRGB 0.000u 0:00.000

Now I convert it:

$ heif-convert pic.heic pic.png 
File contains 2 images
Written to pic-1.png
Written to pic-2.png

And I can view it normaly. EOG (Eye of Gnome) displays them just fine, although it shows just the first picture of the heif container, not the second. But thats it. Conversion works here.

1 Like

oops - sorry!

As I said - I’d need to read and re-learn how to do it and without an actual file like yours to test this on this is just ineffective as of now.
So: no - sorry.
It’s not even sure that this is the correct approach.
We don’t know how the many pictures are stored inside that .heic container - or in which form.

This surely gives some result with your file - maybe that helps you further?

1 Like
$ identify Big\ Sur.heic                             
Big Sur.heic HEIC 354x200 354x200+0+0 8-bit sRGB 75819B 0.010u 0:00.004

It tells me that it just has one. But I wonder how come a file with just one image have size equal to 500 Mb. If I view the same image in Preview application in macbook I see this which means it must have images inside of it.

I think it is one of those apple proprietary thing. Ahh !! I really hate that. I have a xml file too that was in the Wallpaper file of mac. I don’t understand it much though !! Will it help ? If yes please let me know

@Unbeknownst

What says:

heif-info Big\ Sur.heic

:question:

# heif-info Big\ Sur.heic                                       ✔ 
MIME type: image/heic
main brand: heic
compatible brands: heic, mif1

image: 354x200 (id=1), primary
  color profile: prof
  alpha channel: no 
  depth channel: no
metadata:
  Exif: 728 bytes
  XMP: 6626 bytes

Here is a link for the original file I have. I am uploading this to this server where you can download and experiment stuff. Expires in 30 days from now.
Server link : https://easyupload.io/m/t6pqm0
The file contains heic and equivalent png file that was converted in macbook.

I have uploaded the original file so you can read, re-learn and experiment around with. I hope that helps :slight_smile:

Hey - I’ll have a look.
Since you said it was a wallpaper and you had an xml file assiciated with it, that would be good to have also.

It so far looks like a misunderstanding - the .heic files are only pretty small while the .png that seems to be associated with it are the big ones (430 - 450 MB)

I thought you only had .heic and wanted to extract from that.

We will figure it out eventually.

1 Like

Here are the contents of the xml file: xml file - Pastebin.com
this file is really weird though.

Ok a quick view give me an idea what is happening here…

  1. the heic file really contains only a low resolution image. No doubt. Just a thumbnail.
  2. The xml file seems to be read on your mac and it downloads the high resolution images.

Is it some sort of icloud? I remember google photos can upload photos, and replace local images with dumb thumbnails, while when you access the file, it streams the data from the cloud and cache it locally.

That could be perfectly the reason, why you don’t see the images on linux, but on apple.

I don’t think I have any way of extracting individual images then :frowning: … do I ?

no - but you can probably download them - the addresses are in the .xml file

1 Like

Not from that existing image. No. You need to download the original pictures, somehow.

btw… when I look at the meta data of the heic, I have found this:

<rdf:li stEvt:action="converted" stEvt:parameters="from image/png to application/vnd.adobe.photoshop"/>

So, the heic file is converted with photoshop from a png file and the png file is the original.