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 will be deprecated soon #1453

Closed
rockstorm101 opened this issue Oct 12, 2024 · 5 comments
Closed

imghdr will be deprecated soon #1453

rockstorm101 opened this issue Oct 12, 2024 · 5 comments
Labels

Comments

@rockstorm101
Copy link
Collaborator

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.

@DivingDuck
Copy link
Collaborator

DivingDuck commented Oct 12, 2024

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.

@DivingDuck
Copy link
Collaborator

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

@neofelis2X
Copy link
Contributor

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.

@rockstorm101
Copy link
Collaborator Author

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.

@DivingDuck
Copy link
Collaborator

Then we can merge it. Thanks for testing 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants