-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
The imghdr module is deprecated in Python 3.11 (see here) and slated for removal in Python 3.13.
imghdr is used to determine image type:
Lines 430 to 435 in 30a7571
| @classmethod | |
| def encodingof(cls, imagebytes): | |
| type = imghdr.what(None, h=imagebytes) | |
| if type == 'jpeg': | |
| return ImageEncoding.JPEG | |
| return ImageEncoding.Unknown # pragma: no cover |
If just looking for the JPEG type, maybe a simple fix to get rid of imghdr would be to look at the signature in the first few bytes of the image data like:
...
# Check for JPEG signature (first three bytes are b'\xFF\xD8\xFF')
if imagebytes.startswith(b'\xFF\xD8\xFF'):
return ImageEncoding.JPEG
return ImageEncoding.Unknown?
ktdreyer, shadchin, petrprikryl, williamfitzGH, jenstroeger and 2 more
Metadata
Metadata
Assignees
Labels
No labels