Bug 1906512 - Porting guide for PNGImageDecoder
Summary: Porting guide for PNGImageDecoder
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-pyglet
Version: 34
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Petr Viktorin (pviktori)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1906363
TreeView+ depends on / blocked
 
Reported: 2020-12-10 17:06 UTC by Jerry James
Modified: 2021-04-20 14:45 UTC (History)
4 users (show)

Fixed In Version: python-pyglet-1.5.16-1.fc35
Clone Of:
Environment:
Last Closed: 2021-04-20 14:45:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jerry James 2020-12-10 17:06:20 UTC
Description of problem:
The python-pyglet spec file contains this:

# Remove the bundled pypng library (python-pillow provides the same functionality)
rm pyglet/image/codecs/png.py
rm pyglet/extlibs/png.py

This has led directly to bug 1906363.  Would you please include a porting guide, perhaps in a README of some kind, that says, "If your application wants to use PNGImageDecoder, then patch it like this"?  I am unfamiliar with both pyglet and pillow, so don't know how to fix bug 1906363.  Please give me a guide.

Version-Release number of selected component (if applicable):
python3-pyglet-1.5.11-1.fc34

How reproducible:
N/A

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Miro Hrončok 2020-12-10 17:26:17 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.

Comment 2 Miro Hrončok 2020-12-10 17:31:15 UTC
> 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

Comment 3 Petr Viktorin (pviktori) 2020-12-14 10:12:31 UTC
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

Comment 4 Petr Viktorin (pviktori) 2020-12-14 10:16:51 UTC
I checked that this works for sympy; see https://src.fedoraproject.org/rpms/sympy/pull-request/3

Comment 5 Ben Cotton 2021-02-09 16:21:12 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 6 Petr Viktorin (pviktori) 2021-04-20 14:45:16 UTC
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!


Note You need to log in before you can comment on or make changes to this bug.