-
Notifications
You must be signed in to change notification settings - Fork 33
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
For Python 3.13: A drop-in replacement for imghdr.what()
#76
Conversation
8aae6d3
to
6fe0635
Compare
I've just had a look at the code and really need to spend some more time on it. These may seem obvious questions but I'm lacking caffeine and sleep (long days this week) so they are just to help me understand a little better:
I can see some improvements for your test strings for PBM, PGM and PPM so I'll add those to my PR later, but that should not affect the basic matches PureMagic already has. UPDATE These improvements are now in my PR. We can detect a SPACE, TAB or Win/*nix newline, additionally if they are immediately followed by a # that will improve confidence as well. |
f27b033
to
0c49122
Compare
imghdr.what()
0f6bf82
to
5b231b7
Compare
Hi @cclauss, you might need to remove the Watching the commits with interest 🙂 |
That |
Ah! Did not notice you had the PR against the develop branch, my bad. 🙂 |
There are certain cases where Do you have suggestions for how we can always deliver identical results as The current definition in this PR is: def what(file: os.PathLike | str | None], h: str | bytes | None) -> str: but I think we should make two changes to deliver optional bug-for-bug compatibility:
Thoughts on naming? The
|
What files/cases are causing issues? Without #75 they may not work or behave as expected at present. Feel free to fling a .zip over or link to an image and I'll take a look. |
I was focused on
It would be wonderful to add more image files in |
Quick breakdown based on #75, I'm assuming you are converting to hex:
The JFIF/EXIF thing is a would be nice to have rather than critical to matching, a JPG will always have the base marker of |
- Adding #72 #75 #76 #81 `.what()` to be a drop in replacement for `imghdr.what()` (thanks to Christian Clauss and Andy - NebularNerd) - Adding #67 Test on Python 3.13 beta (thanks to Christian Clauss) - Adding #77 from __future__ import annotations (thanks to Christian Clauss - Fixing #66 Confidence sorting (thanks to Andy - NebularNerd) --------- Co-authored-by: Andy <NebularNerd@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
Closes #72
imghdr.what()
#72This might be more complete after #75 lands.
Current pytest results:
53 passed in 0.05s
test_what_from_file
is 6 teststest_what_from_file_none
is 1 testtest_what_from_string
is 38 teststest_what_from_string_py311
is 2 testsimghdr
only on Python < 3.11test_what_from_string_todo
is 6 testspuremagic
@NebularNerd Your reviews, please.