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 not dump exif_dict : dump got wrong type of exif value. 41729 in Exif IFD. #95

Open
jdhao opened this issue Jul 31, 2019 · 15 comments

Comments

@jdhao
Copy link

jdhao commented Jul 31, 2019

This issue is related to #83. When I want to dump the modified exif dict into to exif bytes using the example here, I got the error:

ValueError: "dump" got wrong type of exif value.
41729 in Exif IFD. Got as <class 'int'>.

After checking the source code a bit, I found that piexif expects this value in key 41729 in Exif IFD to be bytes instead of ints. So I change the value to bytes:

exif_dict['Exif'][41729] = b'1'

Then I can dump the exif dict without any error.

@dmitrybelyakov
Copy link

Same issue here.

@charisti5676
Copy link

SUKA !@ SAME HERE LOL :(

@nkacoroski
Copy link

I get a similar issue for Exif tag code 41988, but changing it to bytes I get same error. It looks like it's supposed to be a rational type... but I didn't think that was really a class in python. Any ideas for a workaround? Thanks.

@jdhao
Copy link
Author

jdhao commented Nov 5, 2019

@nkacoroski you may have to check the source code and see what data type it expects.

@nkacoroski
Copy link

@jdhao How do I do that?

@jdhao
Copy link
Author

jdhao commented Nov 5, 2019

@nkacoroski
When piexif gives an error, there are stack traces, you should be able to pinpoint which source file to look at.

Read the relevant source code of piexif and run your code with a debugger to see where it fails. Then you should be able to see what data type it expects.

@nkacoroski
Copy link

Okay, thank you!

@Xima
Copy link

Xima commented Jan 8, 2020

Got the same issue.
from the standard p.67 : http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf
this tag has TYPE : undefined. So piexif should not expect exclusively a byte.
I can make the workaround for this tag, but what if it happens with another tag ? Can we expect a patch for this ?

@ImLucasBrown2
Copy link

ImLucasBrown2 commented Jan 30, 2020

What's a good workaround for this? I literally can't run the example code on my images.

exif_dict = piexif.load(file_path)
exif_bytes = piexif.dump(exif_dict)

ValueError: "dump" got wrong type of exif value.
41729 in Exif IFD. Got as <class 'int'>.

I don't fully understand what's going on in _dump but it seems that at least one of the TAGS has the wrong type.
My work around was to change line 623:
From
41729: {'name': 'SceneType', 'type': TYPES.Undefined}
to
41729: {'name': 'SceneType', 'type': TYPES.Short}

@kkava
Copy link

kkava commented Feb 24, 2020

I'm also having this issue. Would be nice to fix it. My workaround will be to simply drop this tag, which is useless anyway. Most images don't even have it, and no modern ones do. Just some old ones I took with a crappy 1st gen smartphone in 2011 are tripping up my code.

    # "dump" got wrong type of exif value.\n41729 in Exif IFD. Got as <class \'int\'>.
    # See bug https://github.com/hMatoba/Piexif/issues/95
    try:
        del newexif['Exif'][piexif.ExifIFD.SceneType]
    except:
        pass

@IvanaGyro
Copy link

Maybe TYPES.Byte should be unpacked with 's' instead of 'B'.

@muelli
Copy link

muelli commented Nov 8, 2020

well, does it work for you?

@Nelorth
Copy link

Nelorth commented Mar 22, 2023

Bumping this, is there any progress on the issue?

@nautatva
Copy link

nautatva commented Dec 2, 2023

This should help

if 41729 in exif_dict['Exif'] and isinstance(exif_dict['Exif'][41729], int):
    exif_dict['Exif'][41729] = str(exif_dict['Exif'][41729]).encode('utf-8')

@bonlime
Copy link

bonlime commented Feb 28, 2024

I was facing the same problem, despite also loading through piexif. The solution for me was to extract exif data BEFORE applying any changes to PIL.Image from which it was taken. Otherwise PIL would decode data in it's own format, which causes this error

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

No branches or pull requests