TypeError: Object of type IFDRational is not JSON serializable
I've updated my web server from Debian Buster (v10) to Bullseye (v11). Now the scanner from the development
branch in the demo site crashes with:
1887132 2021-11-05 09:13:40.424158 [saving all unprotected albums to json files...]
129 2021-11-05 09:13:40.424287 [Saving password/codes files...]
601 2021-11-05 09:13:40.424888 [saving all physical albums to json files...]
Traceback (most recent call last):
File ".../myphotoshare/scanner/main.py", line 57, in <module>
main()
File ".../myphotoshare/scanner/main.py", line 38, in main
TreeWalker()
File ".../myphotoshare/scanner/TreeWalker.py", line 155, in __init__
self.all_albums_to_json_file(album)
File ".../myphotoshare/scanner/TreeWalker.py", line 231, in all_albums_to_json_file
self.all_albums_to_json_file(subalbum, complex_identifiers_combination)
File ".../myphotoshare/scanner/TreeWalker.py", line 231, in all_albums_to_json_file
self.all_albums_to_json_file(subalbum, complex_identifiers_combination)
File ".../myphotoshare/scanner/TreeWalker.py", line 391, in all_albums_to_json_file
album.to_json_file(
File ".../myphotoshare/scanner/PhotoAlbum.py", line 548, in to_json_file
json.dump(self, file, sep_pos = separate_positions, sep_media = separate_media, cls = PhotoAlbumEncoder)
File "/usr/lib/python3.9/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/usr/lib/python3.9/json/encoder.py", line 439, in _iterencode
yield from _iterencode(o, _current_indent_level)
File "/usr/lib/python3.9/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.9/json/encoder.py", line 325, in _iterencode_list
yield from chunks
File "/usr/lib/python3.9/json/encoder.py", line 439, in _iterencode
yield from _iterencode(o, _current_indent_level)
File "/usr/lib/python3.9/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/lib/python3.9/json/encoder.py", line 438, in _iterencode
o = _default(o)
File ".../myphotoshare/scanner/PhotoAlbum.py", line 2952, in default
return json.JSONEncoder.default(self, obj)
File "/usr/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type IFDRational is not JSON serializable
The problem seems related to the new version of Pillow v8 that uses the type IFDRational
to store GPS information in EXIF.