Skip to content

Image.palette modified after calling show() or save() #718

Description

@zhyang-liu

When an Image object is using palette, calling method Image.save() and Image.show() modifies Image.palette and Image.palette.save() throws an exception ValueError: palette contains raw palette data. The figure below shows the code and the exception. Please take a look at lines that commented out and the console output number 768.

1

After uncommenting the show() method, the exception disappeared, and the length of palette.palette was still 768.
2

But when I only use the save() method and comment out the show() method, the length will be 600, as I specified colors=200 before.
3

I don't think a show() or save() method should modify the origin object, and I also think the palette of a converted palette picture should be able to save its palette directly, without saving or taking a glance at first.

Activity

  1. added this to the 2.6.0 milestone on Jul 2, 2014
  2. modified the milestones: 2.6.0, 2.7.0 on Oct 26, 2014
  3. radarhere commented on May 14, 2015

    @radarhere
    Member

    With regards to the saving of raw palette data, the same warning applies to the getcolor and tobytes method as well. Each time the code is as simple as -

    if self.rawmode:
        raise ValueError("palette contains raw palette data")
    

    If the consensus is that any of these methods should be enabled for rawmode, and if there is confidence that the rawhide data isn't sufficiently different to cause problems, then it's just a matter of removing those lines.

  4. removed
    BugAny unexpected behavior, until confirmed feature.
    on Jul 8, 2015
  5. modified the milestones: 2.7.0, Future on Jul 8, 2015
  6. radarhere commented on Jul 8, 2015

    @radarhere
    Member

    Since #1231 has been merged, the bug portion of this issue - the palette being modified - has been fixed. The remainder of this issue is about potentially changing the deliberate behaviour of the code - the ValueError raised when in rawmode.

  7. added
    BugAny unexpected behavior, until confirmed feature.
    and removed
    BugAny unexpected behavior, until confirmed feature.
    on Jan 5, 2017
  8. aclark4life commented on Jan 5, 2017

    @aclark4life
    Member

    Or alternatively can we close this and change the milestone to Never?

  9. removed this from the Future milestone on Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions