Skip to content

fix: exiftool JSON output decoded with locale encoding instead of UTF-8 #1972

@hanhan761

Description

@hanhan761

ExifTool always outputs JSON in UTF-8, but the exiftool_metadata() function decodes the output using locale.getpreferredencoding(). On systems where the locale encoding is not UTF-8 (e.g., Windows with Chinese locale uses cp936/GBK), this can cause a UnicodeDecodeError when exiftool returns metadata containing non-ASCII characters.

Reproduction:

  1. Use Windows with Chinese locale (cp936)
  2. Run exiftool on an image with non-ASCII metadata
  3. exiftool_metadata() raises UnicodeDecodeError

Expected: JSON output decoded as UTF-8 (which is always the correct encoding for JSON per RFC 8259).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions