-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Replace imghdr
by puremagic
#19074
base: dev
Are you sure you want to change the base?
Replace imghdr
by puremagic
#19074
Conversation
713f3de
to
9b436f3
Compare
imghdr allowed to detect a few imagetimes and has been deprecated in python 3.13: https://docs.python.org/3.12/library/imghdr.html from the release notes: > The filetype, puremagic, or python-magic libraries should be used as replacements. > For example, the puremagic.what() function can be used to replace the imghdr.what() > function for all file formats that were supported by imghdr. See also https://github.com/cdgriffith/puremagic/blob/763349ec4d02ba930fb1142c6eb684afdf06c6ab/puremagic/main.py#L421
9b436f3
to
6fb95f7
Compare
Also dropping the import (as in #18449) at all would be fine for me (was also my first idea). Maybe we can split this out in a separate PR? I did a few experiments with puremagic (for the sniffers for binary formats) ... which were not really promising (i.e. mostly false negatives). |
Not an expert in this, I am happy to backport my commit dropping imghdr if puremagic isn't that useful. |
We only seem to use image_util from lib/galaxy/datatypes/images.py - it should probably be moved to galaxy-data - where the requirements make a lot more sense also. |
I did try that, but |
It has been in datatypes until 2016 #3042 |
imghdr
allowed to detect a few image types and has been deprecated in python 3.13from the release notes:
See also code comment
Since we do not really know how often PIL fails nowadays, we could also drop it. Overall I could imagine that puremagic could help us as well for the datatype sniffing (I think over there we reinvent the wheel from time to time).
The number of supported filetypes and being python only seems also in favor of
puremagic
(compared to filetype and python-magic)Stumbled over this here: galaxyproject/bioblend#472
How to test the changes?
(Select all options that apply)
License