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
Helpful error message on encode/decode #6310
Conversation
Researching more it looks like the entire code paths for DECODERS/ENCODERS/register_encoder/register_decoders and Image.to_bytes is just some unused code that doesn't work anymore? ENCODERS doesn't seem like it can ever be filled with "jpeg" for example, or anything else... |
#6069 added complete support for Pillow/src/PIL/BlpImagePlugin.py Line 484 in 6bb408c
|
So Within Line 424 in 6bb408c
Here is a list of the C codecs - Lines 4025 to 4061 in 6bb408c
So your suggested error message would only report the Python codecs, and ignore the possible C codecs that could be used. |
Hmm. Yea I see your point. I guess a good error message would then also have to do something like c_encoders = [x for x in dir(core) if x.endswith('_encoder')] And join ENCODERS with this c_encoders before producing the error message. |
This may just be my opinion, but doesn't a list of up to 21 different possible decoders make for a pretty long error message? |
Why is the length relevant? If it contains information that lets you solve the problem you are happy. If it does not, then you are unhappy. I gave up on using this API totally because I couldn't figure out a valid encoding name. I used |
While I don't know exactly what your goal was, that may have been the actual solution to your problem. The documentation for
Also, just to point this out, if I try from PIL import Image
im = Image.new("RGB", (1, 1))
im.tobytes("jpg") I get
Which is something of a helpful error message already. |
I've created #6415 as an alternative to this, adding notes to the documentation on where to find other decoders. |
Changes proposed in this pull request: