OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

[BUG] HEIF from Sony ILCE-7M4 opens incorrectly

Open AdamMainsTL opened this issue 1 year ago • 3 comments

Describe the bug Opening a HEIF image produced from a Sony ILCE-7M4 camera opens with the incorrect dimensions and image data tiled incorrectly. Example of image + issue below.

I have tried to update to the latest libheif with same results. I am not familiar enough with the code to know whether the issue lies in how OIIO is calling into libheif or if libheif itself is wrong.

To Reproduce Steps to reproduce the behavior:

  1. Run oiiotool "Johannes Klauser - DSC00443.HEIF" -o out.png
  2. out.png will contain incorrect image data

Expected behavior Dimensions should be correct and image data should not be duplicated.

Evidence Original image (posted with permission from creator): Johannes Klauser - DSC00443.HEIF.zip

Output from oiiotool, resized for github. Original dimensions 7008x4672 (opposite of original): out_resized

Platform information:

  • OIIO branch/version: 2.4.11.1
  • OS: Mac (likely on Windows too)
  • C++ compiler: apple-clang 14.0.0
  • Any non-default build flags when you build OIIO:

AdamMainsTL avatar May 30 '23 14:05 AdamMainsTL

Interesting. Same issue have Affinity Photo 2. but heif-convert.exe from libHEIF correctly decode this image.

I found another bug with libHeif and will looks deeper into OIIO plugin as soon as HEIF with a RAWs is important for my projects.

ssh4net avatar Mar 11 '24 09:03 ssh4net

I understand the issue. Sony HEIF file have 90 degree rotation, when OIIO open it as horizontal (0 degree) rotated image. Digging deeper

ssh4net avatar Mar 11 '24 13:03 ssh4net

@lgritz I found that the example image stores these extra attributes

oiio:OriginalOrientation : 6
Orientation : 1

and using config["oiio:reorient"] = 0; trow exception in

HeifInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/, void* data)

probably due to a mismatch in image width and height.

ssh4net avatar Mar 12 '24 07:03 ssh4net