libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Basic reading and writing of heif files

Open elibendavid opened this issue 6 years ago • 10 comments

Hi,

Trying to get some basic functionality going on for heif in --> heif out. target file gets created with small size and no image data the original heif is apple created ( grid image )

Is this type of implementation supposed to work ?

heif_context * hc = heif_context_alloc();
heif_context_read_from_file(hc,file_name.c_str(),0);
heif_context_write_to_file(hc,outfile_name.c_str());
heif_context_free(hc);

Thanks

elibendavid avatar Jan 22 '19 11:01 elibendavid

No, libheif does not support modifying existing files yet. They can be read or created from scratch, but not modified.

farindk avatar Aug 16 '19 10:08 farindk

I see. In that case I would be very helpful to know if libheif has evolved to allow the following :

  • Is there anyway to get the encoded hevc data without using a dummy decoder ?
  • Is there anyway to write a new heif file but supply pre-encoded hevc data ( no dummy encoder..) ?

Many thanks -Eli

elibendavid avatar Aug 17 '19 08:08 elibendavid

But you only need to re-create the container file structure, not re-encoding the image data itself?

phako avatar Oct 14 '19 14:10 phako

@phako yes, that is correct, the encoding will take place in a different library.

elibendavid avatar Oct 14 '19 15:10 elibendavid

This is a patch with a proof of concept CLI tool dedicated to patch an HEIF file with 3 metadata chunks : Exif, Iptc, and Xmp. Chunk files are attached as zip archive and are extracted from a JPEG file using exiftool.

updatemetadata.patch.txt metadata-chunks.zip

The goal of this tool is to open an HEIF file and to replace all metadata chunk without to re-encode the image. This kind of concept can be improved to patch ICC color chunk too.

If this king of tool can work with a modified libheif, well Exiv2 shared library will use a similar code to write metadata in HEIF container.

Gilles Caulier

cgilles avatar Oct 14 '19 19:10 cgilles

Ping ? Did you take a look to my patch and my comment from my previous post ?

Thanks in advance

Gilles Caulier

cgilles avatar Nov 11 '19 10:11 cgilles

Please provide patches as pull-request so they are easier to review / comment on.

fancycode avatar Nov 11 '19 10:11 fancycode

No need to create a PR for this patch, as it add only a new C++ CLI tool in compilation chain. That all...

The zip file contains .dat file for exif, iptc, and xmp chuncks taken from a JPEG image. the CLI tool load these byte-array to replace exif, iptc, and xmp in a target HEIF image.

The result give of course a broken target file as libheif is not able to play with metadata chunck without re-encoding.

Gilles Caulier

cgilles avatar Nov 11 '19 10:11 cgilles

Any news on this?

lillolollo avatar Aug 05 '23 19:08 lillolollo

Any news on this?

YeellowDuck avatar Jun 20 '24 12:06 YeellowDuck