libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Handle Canon .HIF files (from 1Dx III)

Open revk opened this issue 4 years ago • 17 comments

The Canon 1Dx III produces HEIF files (extension .HIF). They work fine on a MAC (once I change file extension tot .heic) , but heif-convert does not work.

Testing on linux.

Initially with the package installed,I got the error about not supporting HEIC, but built from latest git clone I now get an error saying JPEG cannot encode >8 bpp.

I don't know if I have missed something obvious, I hope so, but it would be nice if it can handle these files. Let me know if anything else I can do to help.

AJKL0035.zip

revk avatar May 03 '20 16:05 revk

That Canon camera writes HDR images (>8 bit). JPEG can only handle 8 bit, hence you get the error. If you output to PNG, it should work.

On the other hand, check out the 'all-rgb' branch of libheif. There is already code in heif-convert to convert this down to 8 bit for JPEG. Just tried with your image and it works.

I'll try to finish the work in this branch next week and merge it to master.

farindk avatar May 03 '20 16:05 farindk

FYI: https://github.com/lclevy/canon_cr3/blob/master/heif.md

lclevy avatar May 03 '20 17:05 lclevy

@lclevy Thank you.

farindk avatar May 03 '20 17:05 farindk

Please tell me if Canon files can be viewed or converted, on which platform, so that I can add libheif in links / tools sections

lclevy avatar May 03 '20 18:05 lclevy

The canon has a feature to convert to jpeg on a picture by picture basis, and I can view on anything Mac or iPhone with no problem (they look really good). It would be nice if the heif-convert could reduce to 8 bit for jpeg, for example as I want to use to make web page index images for my stored photos (which I would them download as HEIC anyway), if that makes sense. I'll try PNG though.

revk avatar May 05 '20 16:05 revk

I'll try the all-rib branch anyway

revk avatar May 05 '20 16:05 revk

Good, the all-rgb branch works - the JPG output looks really dull for some reason, but that is a good start, thanks.

revk avatar May 05 '20 17:05 revk

It looks dull because of the PQ color profile used by Canon. That will have to be handled by a color-profile management system.

farindk avatar May 05 '20 17:05 farindk

OK two more issues related to this - one if that the orientation is not right on the JPEG for some reason. The other is that the colour is extremely dull, so probably needs some adjustment as part of the conversion to get remotely close. If anything I can do to help, do let me know. Excellent tool, thank you.

revk avatar May 05 '20 17:05 revk

If you could upload an image with wrong orientation, that would help, as I don't have such a camera. Thank you.

farindk avatar May 05 '20 17:05 farindk

OK attached is a zip that includes:-

  1. The original HIF from the camera
  2. A JPG of the same image as converted from HEIF by the camera
  3. A JPG as converted using heif-convert (all-rgb branch cloned yesterday)

From what I have been reading, it should not be hard to sort orientation, let me know if I can assist in any way.

As for the colour, I assume it is a result of the image being a HDR, so even some option on heif-convert to brighten it up a bit would be helpful :-)

I hope that helps.

Ha, cannot upload the ZIP as too big, LOL, so here... https://www.me.uk/Canon1DxIIIExamples.zip

revk avatar May 06 '20 09:05 revk

The colour issue is interesting - converting on a mac by exporting from preview I get a JPEG that has a colour profile of Rec. ITU-R BT.2020; SMPTE ST 2084 PQ. The JPEG itself then breaks if I send it to twitter, etc, but there are tools I can use to convert the colour profile separately. It sounds like the conversion to JPEG is not saving the original colour profile from the HEIF.

revk avatar May 12 '20 11:05 revk

hi @revk could you please send me a craw + jpeg from your 1dxm3 ? maybe 1 second with dust removal info ?

lclevy avatar May 27 '20 17:05 lclevy

More than happy to do any test images.

Do these help... https://www.me.uk/AJKL0637.HIF https://www.me.uk/AJKL0637.CR3 https://www.me.uk/AJKL0638.HIF https://www.me.uk/AJKC0638.CR3 https://www.me.uk/AJKL0639.JPG https://www.me.uk/AJKL0640.JPG

That should be RAW and CRAW with HIF, and final two are on-camera HIF->JPG for first two.

revk avatar May 28 '20 05:05 revk

Concerning the HEIF->JPEG image rotation problem. I have opened a separate task for that (#227). The rotation is in fact correctly handled by libheif, but since the Exif data is copied to the JPEG output, the JPEG will be rotated again in the viewer. We should remove the Orientation tag from the Exif data, but need an Exif-parser for that.

farindk avatar Jun 03 '20 10:06 farindk

I could use a little help with this if possible. I have been using libheif/libde265 in an image browser I have written in Qt/c++ and it has worked for iphone heic images. However it is not accepting the CR3 images. I get the error "Unsupported file-type: Unspecified: File does not support the 'heic' brand.".

I am using the latest master branch of libheif and the frame-parallel branch of libde265.

Here is a code snip:

heif_context* ctx = heif_context_alloc(); auto error = heif_context_read_from_file(ctx, fPath.toLatin1().data(), nullptr); // error generated error.mesage = Unsupported file-type: Unspecified: File does not support the 'heic' brand.

Here is the test image 1DX3

Thanks for all the work you have done on this excellent library!

Regards Rory

towhee avatar Jun 25 '20 02:06 towhee

Recently got a Canon R5 and I think that I'm seeing a similar problem with the HIF files that it generates. I noticed above that the all-rgb branch works, but it is fairly behind main at this point. Is that the best option? Thanks.

ted-gould avatar Jun 07 '21 03:06 ted-gould