-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improved ImagePalette #5552
Merged
Merged
Improved ImagePalette #5552
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dc89f0e
Set colors
radarhere 4d36fee
Set palette to be empty by default
radarhere 3b9792a
Convert getcolor input to RGBA if that is the palette mode
radarhere f3451ae
Convert opaque RGBA color to RGB if that is the palette mode
radarhere fa55927
When allocating a new color, repurpose an unused index if necessary
radarhere 8210645
If all 256 colors are in use, then there is no need for an additional…
radarhere b6b362c
Set color after attaching palette in expand()
radarhere 9192a33
Removed unnecessary load()
radarhere 1606d9a
Removed code from before Python 3.2
radarhere 59a3e3b
Rearranged code to limit line length
radarhere 450382f
Do not use raw ImagePalette
radarhere 7005e66
Use first index for repeated color
radarhere 804183c
Only use an RGBA palette for images with an alpha channel
radarhere 6db0e96
Ensure image is loaded in remap_palette
radarhere 4616288
Disposal method 2 is transparency or black when saving
radarhere 1ee30de
Fixed reloading palette
radarhere File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,9 +157,16 @@ def test_scale(): | |
|
||
|
||
def test_expand_palette(): | ||
im = Image.open("Tests/images/hopper.gif") | ||
im_expanded = ImageOps.expand(im) | ||
assert_image_equal(im_expanded.convert("RGB"), im.convert("RGB")) | ||
im = Image.open("Tests/images/p_16.tga") | ||
im_expanded = ImageOps.expand(im, 10, (255, 0, 0)) | ||
|
||
px = im_expanded.convert("RGB").load() | ||
assert px[0, 0] == (255, 0, 0) | ||
|
||
im_cropped = im_expanded.crop( | ||
(10, 10, im_expanded.width - 10, im_expanded.height - 10) | ||
) | ||
assert_image_equal(im_cropped, im) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
def test_colorize_2color(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using https://pypi.org/project/apng/ to split Tests/images/apng/mode_palette_alpha.png into frames, this matches the transparent third frame