SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.37k stars 312 forks source link

DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13 #631

Open anderspetersson opened 3 months ago

anderspetersson commented 3 months ago

easy-thumbnails==2.8.5 python3.11

easy_thumbnails/optimize/post_processor.py:3:

DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13 from imghdr import what as determinetype

Here is how https://github.com/streamlit/streamlit migrated from imghdr to using Pillow functionality: https://github.com/streamlit/streamlit/commit/3d5dd61aef2bf649c5bfe42aad53cf1426beb094

benkonrath commented 1 week ago

The file is already open in the streamit example which is why they just use PIL. For easy-thumbnails, I think we'll need to use one of the suggested replacements found in the deprecation table, or 'vendor' the imghdr module into the code base (licenses have to allow this of course).

https://peps.python.org/pep-0594/#deprecated-modules

If we use one of the suggested libraries, care needs to be taken to ensure it produces the same result. e.g. 'jpeg' for Jpegs and not 'jpg', 'JPEG', 'JPG', etc.