exiftool *Warning* *Invalid EXIF text encoding for UserComment* if specify more than 8 characters #6

Open
opened 2025-11-20 16:50:58 +01:00 by Benjamin_Loison · 3 comments

See Benjamin_Loison/firefox/issues/200#issuecomment-8375424.

Searching upstream open and closed issues and pull requests for "Invalid EXIF text encoding for" does not return anything.

Related to #5.

See [Benjamin_Loison/firefox/issues/200#issuecomment-8375424](https://codeberg.org/Benjamin_Loison/firefox/issues/200#issuecomment-8375424). Searching upstream open and closed issues and pull requests for `"Invalid EXIF text encoding for"` does not return anything. Related to #5.
Author
Owner

DuckDuckGo and Google search "Invalid EXIF text encoding for" and "Invalid EXIF text encoding for" "8".

Note that whole UserComment is still retrievable with exiftool.

DuckDuckGo and Google search `"Invalid EXIF text encoding for"` and `"Invalid EXIF text encoding for" "8"`. Note that whole *UserComment* is still retrievable with `exiftool`.
Author
Owner
Error:
Traceback (most recent call last):
  File "<tmp 1>", line 6, in <module>
    exif[0x9286] = ('a' * 8).encode('unicode')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LookupError: unknown encoding: unicode
<details> <summary>Error:</summary> ``` Traceback (most recent call last): File "<tmp 1>", line 6, in <module> exif[0x9286] = ('a' * 8).encode('unicode') ^^^^^^^^^^^^^^^^^^^^^^^^^^^ LookupError: unknown encoding: unicode ``` </details>
Author
Owner

DuckDuckGo and Google search "LookupError: unknown encoding: unicode".

DuckDuckGo search Python unicode string.

https://docs.python.org/3/howto/unicode.html

exif[0x9286] = ('a' * 8).encode()

results in the warning.

python-pillow/Pillow/issues/5254

DuckDuckGo and Google search JIS.

Wikipedia: JIS (1187947658)

Python script:
from PIL import Image

imageCropped = Image.new('RGB', (100, 100))

exif = imageCropped.getexif()
PREFIX = 'ASCII'
exif[0x9286] = (PREFIX + (8 - len(PREFIX)) * ' ' + 'a' * 8).encode('ascii')
imageCropped.save('test.png', exif = exif)
exiftool test.png 
Output:
ExifTool Version Number         : 12.76
File Name                       : test.png
Directory                       : .
File Size                       : 163 bytes
File Modification Date/Time     : 2025:12:26 21:21:50+01:00
File Access Date/Time           : 2025:12:26 21:21:41+01:00
File Inode Change Date/Time     : 2025:12:26 21:21:50+01:00
File Permissions                : -rw-rw-r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 100
Image Height                    : 100
Bit Depth                       : 8
Color Type                      : RGB
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Exif Byte Order                 : Big-endian (Motorola, MM)
User Comment                    : aaaaaaaa
Image Size                      : 100x100
Megapixels                      : 0.010
DuckDuckGo and Google search `"LookupError: unknown encoding: unicode"`. DuckDuckGo search *Python unicode string*. https://docs.python.org/3/howto/unicode.html ```python exif[0x9286] = ('a' * 8).encode() ``` results in the warning. [python-pillow/Pillow/issues/5254](https://github.com/python-pillow/Pillow/issues/5254) DuckDuckGo and Google search *JIS*. [Wikipedia: JIS (1187947658)](https://en.wikipedia.org/w/index.php?title=JIS_encoding&oldid=1187947658) <details> <summary>Python script:</summary> ```python from PIL import Image imageCropped = Image.new('RGB', (100, 100)) exif = imageCropped.getexif() PREFIX = 'ASCII' exif[0x9286] = (PREFIX + (8 - len(PREFIX)) * ' ' + 'a' * 8).encode('ascii') imageCropped.save('test.png', exif = exif) ``` </details> ``` exiftool test.png ``` <details> <summary>Output:</summary> ``` ExifTool Version Number : 12.76 File Name : test.png Directory : . File Size : 163 bytes File Modification Date/Time : 2025:12:26 21:21:50+01:00 File Access Date/Time : 2025:12:26 21:21:41+01:00 File Inode Change Date/Time : 2025:12:26 21:21:50+01:00 File Permissions : -rw-rw-r-- File Type : PNG File Type Extension : png MIME Type : image/png Image Width : 100 Image Height : 100 Bit Depth : 8 Color Type : RGB Compression : Deflate/Inflate Filter : Adaptive Interlace : Noninterlaced Exif Byte Order : Big-endian (Motorola, MM) User Comment : aaaaaaaa Image Size : 100x100 Megapixels : 0.010 ``` </details>
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/Pillow#6