imghdr will be deprecated soon
Closed this issue · 5 comments
Originally reported by Louis-Philippe Véronneau.
imghdr
will be deprecated with Python 3.13. A replacement could be filetype
, though the API is completely different so it will require some work.
Hi,
Looking at https://peps.python.org/pep-0594/#imghdr and the recommended replacement alternatives I tend a bit more to puremagic. It looks like a easy usable drop-in replacement. In addition it seems to be a living project. What ever this means...
With filetype and python-magic I have mixed feelings as both don't look like active projects. Python support is shown up to version 3.9.
What do you think about it?
Edit:
I just make a quick temporary test and modified the code in projectlayer.py for the module puremagic. Seems to work.
This is a quick one: PR#1455
Test needed for Linux and macOS version of pronterface.
Artifacts:
Windows: https://github.com/kliment/Printrun/actions/runs/11306128512
macOS: https://github.com/kliment/Printrun/actions/runs/11306128506
Python sdist and wheels: https://github.com/kliment/Printrun/actions/runs/11306128509
Test files used in Pronterface -->Tools -->Projector: ProjectorTestFiles.zip
One is for .svg format and one for Prusa .sl1s format
Hello,
that was fast! I would have suggested that we can remove imghdr and just look at the file extensions. Because in this usecase the images should always have a correct file extension (.png in most cases). But this solution is good too!
I tested it on macOS and it works fine.
Looking at https://peps.python.org/pep-0594/#imghdr and the recommended replacement alternatives I tend a bit more to puremagic. It looks like a easy usable drop-in replacement. In addition it seems to be a living project. What ever this means...
With filetype and python-magic I have mixed feelings as both don't look like active projects. Python support is shown up to version 3.9.
What do you think about it?
I did not investigate other alternatives really. puremagic
looks like it has a closer API to what we had so I think you are right and it is the best bet.
Test files used in Pronterface -->Tools -->Projector: ProjectorTestFiles.zip
One is for .svg format and one for Prusa .sl1s format
I did a quick test on Linux though I don't have a resin printer or the like. No errors thrown so it looks OK to me. I'm happy to merge #1455 if you want.
Then we can merge it. Thanks for testing 🙂