FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support more options for reading/writing images in Tkinter · Issue #118271 · python/cpython · GitHub

Repository navigation

Support more options for reading/writing images in Tkinter #118271

Closed

Description

Feature or enhancement

PhotoImage has method write() which writes the image (or its part) to the file. But it lacks methods for two other related subcommand -- read, to read the image from the file, and data, to get the image data. I propose to add methods read() and data().

Also, the write() method can support two new options: background and grayscale.

Linked PRs

Activity

  1. serhiy-storchaka commented on Apr 25, 2024

    MemberAuthor

    Note that some Tk commands have options which cannot be directly translated to Python parameters: class, in, from. Usually this is worked around by adding an underscore at the end. But in PhotoImage.write() the -from option was translated to from_coords. There is a precedence of using from_ in other place, so I used from_ in the new copying method (#118225) and in read() added here. It creates inconsistency with the write() method. Maybe we should use from_coords in all PhotoImage methods?

    cc @terryjreedy

  2. serhiy-storchaka commented on Apr 25, 2024

    MemberAuthor

    Yet one note: read -from does not work correctly with GIF and PNG images, unlike to copy -from. This is an old Tk bug https://core.tcl-lang.org/tk/tktview/1576528. A workaround is to read the whole file and then copy a region from the new image by using the new copying method.

    We may get reports about broken behavior when people start to use the new method with this option, but I think that it is worth to implement it. The Tk bug can finally be fixed in the future releases, and it works at least with PPM files.

  3. added 2 commits that reference this issue on Apr 25, 2024
  4. added a commit that references this issue on May 6, 2024
  5. added a commit that references this issue on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL