Expand .ani and .cur functionality#6606
Open
jlwoolf wants to merge 82 commits intopython-pillow:mainfrom
Open
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Author
|
Turns out it was much easier to implement .cur file saving (as it shares a lot with ICO). So I remodified CurImagePlugin to add that functionality. I reverted the BmpImagePlugin changes. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Author
|
Alright, made some significant modifications. I believe I have mostly resolved all the .cur file issues, but tests need to be written for a few. I have also further expanded this functionality to work with .ani files. You can now read and write them. I also plan to work on tests for them in the future. |
radarhere
reviewed
May 4, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently the BmpImagePlugin checks if a file is a .cur file by checking if the bits are 32 and a the header is 22. However, the header for cursor files is not guaranteed to be 22.
The CurImagePlugin selects the largest cursor image from the file. The largest cursor does not have to be at the front of the file. So the start of the DIB header file varies depending on the file.
The fix below initializes a parameter in the CurImagePlugin (if it is in fact a .cur file) so that transparency is considered. It might be worth modifying CurImagePlugin to work similarly to IcoImagePlugin however. I'm looking into that right now, but this is a simple fix.