Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load PNG produced by Blender 3.6 #2745

Closed
theres1 opened this issue Aug 22, 2023 · 5 comments
Closed

Can't load PNG produced by Blender 3.6 #2745

theres1 opened this issue Aug 22, 2023 · 5 comments
Labels

Comments

@theres1
Copy link

theres1 commented Aug 22, 2023

Describe the bug

I use Python bindings https://github.com/LeoHsiao1/pyexiv2 though I think the problem is related to exiv2 library itself.
Problem: Can't load PNG file saved by Blender 3.6. I get error: RuntimeError: This does not look like a TIFF image

Exception from Python:

    with pyexiv2.Image(self.prev.filepath) as img:
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\pyexiv2\core.py", line 15, in __init__
    self.img = exiv2api.Image(filename.encode(encoding))
RuntimeError: This does not look like a TIFF image

To Reproduce

Steps to reproduce the behavior:

  1. Save render in Blender 3.6 (specifically this version) or use image provided by me
    blender 3 6 image
  2. Load image via pyexiv2.Image(filepath) (Python bindings)

Expected behavior

PNG produced by other programs load without problems.

Desktop (please complete the following information):

@theres1 theres1 added the bug label Aug 22, 2023
@kmilos
Copy link
Collaborator

kmilos commented Aug 22, 2023

I can reproduce this w/ 0.27.7 exiv2 CLI, thanks for the sample.

The "This does not look like a TIFF image" is not related to the PNG image itself, but presumably to the eXIf chunk which is supposed to be based on the TIFF spec...

@kmilos
Copy link
Collaborator

kmilos commented Aug 22, 2023

There are actually 2 (identical!) eXIf chunks in this PNG file, but very short so might not carry any significant metadata:

$ exiv2 -pS 262298280-d31e764a-7898-4ca7-b09c-9766c0dec23f.png
STRUCTURE OF PNG FILE: 262298280-d31e764a-7898-4ca7-b09c-9766c0dec23f.png
 address | chunk |  length | data                           | checksum
       8 | IHDR  |      13 | ...`...6....                   | 0xb72d0b85
      33 | eXIf  |      54 | MM*........H.......H.......... | 0x6c37252a
      99 | oFFs  |       9 | ........                       | 0xda2ab6ce
     120 | pHYs  |       9 | .........                      | 0xd2dd7efc
     141 | tEXt  |      15 | File.<untitled>                | 0x95b3d796
     168 | tEXt  |      24 | Date.2023/08/22 10:54:21       | 0x6c56e2d2
     204 | tEXt  |      16 | Time.00:00:00:01               | 0xecc326c2
     232 | tEXt  |       9 | Frame.001                      | 0xc1511522
     253 | tEXt  |      13 | Camera.Camera                  | 0x68ffefe9
     278 | tEXt  |      11 | Scene.Scene                    | 0xe5215d96
     301 | tEXt  |      19 | RenderTime.00:00.31            | 0xfc1d3d14
     332 | IDAT  |    2784 | h..[]o....(9...#...d..`..-f... | 0x07fa723d
    3128 | eXIf  |      54 | MM*........H.......H.......... | 0x6c37252a
    3194 | IEND  |       0 |                                | 0xae426082

@kmilos
Copy link
Collaborator

kmilos commented Aug 22, 2023

Btw, exiftool -v3 also warns about overlapping TIFF directories, so at least that should be reported to Blender as well:

PNG eXIf (54 bytes):
      0c40: 4d 4d 2a 00 00 00 00 18 00 00 00 48 00 00 00 01 [MM*........H....]
      0c50: 00 00 00 48 00 00 00 01 00 02 01 1a 00 05 00 00 [...H............]
      0c60: 00 01 00 00 00 08 01 1b 00 05 00 00 00 01 00 00 [................]
      0c70: 00 10 00 00 00 00                               [......]
  + [TIFF directory]
  | ExifByteOrder = MM
  | Warning = IFD0 pointer references previous IFD0 directory
PNG IEND (end of image)

@kmilos
Copy link
Collaborator

kmilos commented Aug 22, 2023

Ok, so the TIFF signature 4d 4d 2a 00 is invalid for this eXIf chunk. For big-endian encoding, it must be 4d 4d 00 2a.

This is a Blender (or whatever library they use to write PNGs) bug.

The only thing exiv2 can do here is perhaps detect this special byteswap case and tolerate it (like exiftool) w/ a warning instead of erroring out...

@kmilos kmilos removed the bug label Aug 22, 2023
lgritz pushed a commit to AcademySoftwareFoundation/OpenImageIO that referenced this issue Sep 13, 2023
When writing out EXIF headers in PNG files, the `tiff_version` field
wasn't handling endianness properly.

This lead to some tools like `exiv2` refusing to process the file at
all[1]

[1] Exiv2/exiv2#2745

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this issue Sep 16, 2023
…demySoftwareFoundation#3984)

When writing out EXIF headers in PNG files, the `tiff_version` field
wasn't handling endianness properly.

This lead to some tools like `exiv2` refusing to process the file at
all[1]

[1] Exiv2/exiv2#2745

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
lgritz pushed a commit to lgritz/OpenImageIO that referenced this issue Sep 20, 2023
…demySoftwareFoundation#3984)

When writing out EXIF headers in PNG files, the `tiff_version` field
wasn't handling endianness properly.

This lead to some tools like `exiv2` refusing to process the file at
all[1]

[1] Exiv2/exiv2#2745

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
@kmilos kmilos added the wontfix label Sep 25, 2023
@kmilos kmilos closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2023
@kmilos
Copy link
Collaborator

kmilos commented Sep 25, 2023

Thanks for addressing this upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants