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

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d #66

Closed
leogitpro opened this issue Jan 11, 2023 · 1 comment
Closed

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d #66

leogitpro opened this issue Jan 11, 2023 · 1 comment

Comments

@leogitpro
Copy link

leogitpro commented Jan 11, 2023

I tested a picture from: https://commons.wikimedia.org/wiki/File:Metadata_test_file_-_includes_data_in_IIM,_XMP,_and_Exif.jpg with code:

        with exiftool.ExifToolHelper(executable=ExifTool(), logger=logger) as et:
            meta = et.get_metadata(self.photo, params=["-s"])

And there is an error raised:

File "C:\Work\share\EF\venv\lib\site-packages\exiftool\helper.py", line 293, in get_metadata
    return self.get_tags(files, None, params=params)
  File "C:\Work\share\EF\venv\lib\site-packages\exiftool\helper.py", line 378, in get_tags
    ret = self.execute_json(*exec_params)
  File "C:\Work\share\EF\venv\lib\site-packages\exiftool\exiftool.py", line 1127, in execute_json
    result = self.execute("-j", *params)  # stdout
  File "C:\Work\share\EF\venv\lib\site-packages\exiftool\helper.py", line 132, in execute
    result: Union[str, bytes] = super().execute(*str_bytes_params, **kwargs)
  File "C:\Work\share\EF\venv\lib\site-packages\exiftool\exiftool.py", line 1018, in execute
    raw_stdout = raw_stdout.decode(self._encoding)
  File "C:\SDK\Python\Python39\lib\encodings\cp1252.py", line 15, in decode
    return codecs.charmap_decode(input,errors,decoding_table)
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 16621: character maps to <undefined>

But in the terminal: exiftool -G -s downloaded.jpg work well. All of the meta information is output correctly.

How to avoid Unicode errors like the result including 0x9d or 0x81, etc...
Thanks.

@sylikc
Copy link
Owner

sylikc commented Jan 11, 2023

Did you fix it with specifying UTF-8 encoding? That's typically the way the string comes out.

In pyexiftool, I intentionally haven't caught those errors, just so that can flow upwards

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

2 participants