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

imghdr is deprecated and slated for removal in Python 3.13 #462

Open
elibon99 opened this issue Dec 1, 2023 · 0 comments
Open

imghdr is deprecated and slated for removal in Python 3.13 #462

elibon99 opened this issue Dec 1, 2023 · 0 comments

Comments

@elibon99
Copy link

elibon99 commented Dec 1, 2023

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:

PGPy/pgpy/constants.py

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

?

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

1 participant