drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.54k stars 475 forks source link

How to extract thumbnail from HEIF/HEIC files #574

Open francobazzigotti opened 2 years ago

francobazzigotti commented 2 years ago

From HeifMetadataReader.ReadMetadata it's easy to obtain "HEIC Thumbnail Data": 'Offset from beginning of file' and 'Data Length' but when I read the corresponding bytes array I don't know how to save them on a JPEG file. Surely the thumbnail bytes are compressed because "HEIC Thumbnail Parameters" width and height are for instance 320 x 240 and 'Pixel Depth in Bits' is 8 8 8, but the Data Length is only about 5KB. The byte array, for instance, starts with ''00 00 2E 78 28 01 AF 88". Maybe it's an HEVC-coded bytes sequence... In that case, how to produce a separate JPEG or, better, HEIC thumbnail file with that byte stream as a master image?

lfcnassif commented 1 year ago

Maybe it's an HEVC-coded bytes sequence...

Were you able to decode this thumbnail data sequence using alternative tools, e.g. ImageMagick? I'm asking because this would be useful for us when generating thumbnails, since I think running ImageMagick on the thumbnail data would be much faster than running on the whole HEIC/HEIF image (currently done by us).