Skip to content
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

Corrected Palm P mode save #8685

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

radarhere
Copy link
Member

Removes an xfail

@pytest.mark.xfail(reason="Palm P image is wrong")
def test_p_mode(tmp_path: Path) -> None:

with the following changes

  1. Always save the colormap for a P mode image, because
    if im.mode == "P":
    # we assume this is a color Palm image with the standard colormap,
    # unless the "info" dict has a "custom-colormap" field

    is an odd assumption.
  2. Use OR instead of AND to apply the custom colormap flag
    flags = flags & _FLAGS["custom-colormap"]
  3. Do not presume that palettes are 256 in length.

At first glance, you might think that

elif colormapmode == "RGBA":
fp.write(
o8(colormap[4 * i])
+ o8(colormap[4 * i + 1])
+ o8(colormap[4 * i + 2])
)

offered support for saving RGBA palettes. But if you look again, you will see that is only writing three values, meaning it's not writing RGBA palettes, it's converting them to RGB. However, getpalette() will only return a RGB palette, so we won't need to worry about handling that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant