Bug 1906512
| Summary: | Porting guide for PNGImageDecoder | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Jerry James <loganjerry> |
| Component: | python-pyglet | Assignee: | Petr Viktorin (pviktori) <pviktori> |
| Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 34 | CC: | mhroncok, orion, pviktori, python-sig |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | python-pyglet-1.5.16-1.fc35 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-04-20 14:45:16 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1906363 | ||
|
Description
Jerry James
2020-12-10 17:06:20 UTC
pyglet itself has:
# Fallback: PIL
try:
from pyglet.image.codecs import pil
add_encoders(pil)
add_decoders(pil)
except ImportError:
pass
# Fallback: PNG loader (slow)
try:
from pyglet.image.codecs import png
add_encoders(png)
add_decoders(png)
except ImportError:
pass
sympy has:
if fmt == "png":
from pyglet.image.codecs.png import PNGImageDecoder
img = image.load(fname, decoder=PNGImageDecoder())
else:
raise ValueError("pyglet preview works only for 'png' files.")
I guess this works:
from pyglet.image.codecs.pil import PILImageDecoder
img = image.load(fname, decoder=PILImageDecoder())
And should support more file types, even. However, this is all only assumptions, I don't know pyglet/sympy internals, just passing by.
> However, this is all only assumptions, I don't know pyglet/sympy internals, just passing by. Verified that it works: https://bugzilla.redhat.com/show_bug.cgi?id=1906363#c1 It is enough to let Pyglet choose an appropriate decoder with:
img = image.load(fname)
I see no reason to force a specific decoder, and the Pyglet docs even discourage it "unless your application has to work around specific deficiences in an operating system decoder"[0].
[0] https://pyglet.readthedocs.io/en/latest/programming_guide/image.html?highlight=PILImageDecoder#loading-an-image
I checked that this works for sympy; see https://src.fedoraproject.org/rpms/sympy/pull-request/3 This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle. Changing version to 34. I've (finally) added a note with a link to the Pyglet docs to the spec file. I don't know of a better place to put it: a README for the RPM would not be much more discoverable, and I'd need to write one to put a note in it :) Thanks for getting in touch! |