-
Notifications
You must be signed in to change notification settings - Fork 382
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 handling of animated images #357
base: main
Are you sure you want to change the base?
Conversation
2c4e35d
to
2a15886
Compare
i added some code to test converting into animated webp before showing the image but it's sometimes causing crashing and i have no idea why, when it works for a small amount of time it seems to work. |
|
Wanted to chime in here with the state of this PR and other relevant developments around the project. #344 was at a sticking point regarding licenses, but is probably going to move forward with pillow-jpegxl-plugin assuming it functions correctly (I need to get my hands on some .jxl files). In the meantime, I've unknowingly implemented some of changes here in #409 - mostly the animated image media type category and some code for loading GIFs into memory rather than streaming them from disk. I would also suggest rebasing this to |
ce2dc6c
to
3fe7d4d
Compare
@CyanVoxel i manually merged the work from the older version of this branch on to |
Are no tests affected by this PR after the gif changes? And is there a way to add missing tests? |
@eivl are there any tests for animated image handling?
probably |
Co-Authored-By: BPplays <58504799+bpplays@users.noreply.github.com>
Co-Authored-By: BPplays <58504799+bpplays@users.noreply.github.com>
3fe7d4d
to
878a873
Compare
@CyanVoxel i think the PR is good enough for you to have another look if you want. |
if hasattr(image, "n_frames"): | ||
if image.n_frames > 1: | ||
self.set_anim_img(filepath, ext, file_bytes, image) |
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.
Just an approval comment: I like the check to see if an image has multiple frames - for some reason Qt displays QMovies a bit strangely compared to static images, so this check is nice for improving the quality of non-animated images that share extensions with animated counterparts (i.e. gif).
ani_img_priority_order = ["jxl", "apng", "png", "webp", "gif"] | ||
|
||
self.preview_anim_img_pil_map = {"apng": "png"} | ||
|
||
self.preview_anim_img_pil_map_args = {"gif": {"disposal": 2}} | ||
|
||
self.preview_anim_img_pil_known_good = {"webp", "gif"} |
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.
There was a lot of this code that I opted to leave out when porting the functionality over due to it being difficult to decipher the purpose of and to trace back what was occurring inside the animated image creation block.
If it's necessary for important additional functionality, I would appreciate some documentation on what exactly all of these maps are being used for and why they need to be used over just loading in the image as a gif/webp.
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.
@CyanVoxel this is for choosing image format priority based on what types are supported for any given version of pillow and qt
-
preview_anim_img_fmts
: this is a list of qmovie supported formats, it also gets sorted base on: -
ani_img_priority_order
: is an order of image extensions that are sorted first inpreview_anim_img_fmts
-
preview_anim_img_pil_map
: this maps what extension to use in pillow, pillow encodes animated pngs with the format 'png' instead of 'apng' so if apng comes up anywhere pillow should use png -
preview_anim_img_pil_map_args
: this is special args pillow should use for specific encoding formats, here gif has a trail on transparency if 'disposal' is not 2, but webp doesn't need it. -
preview_anim_img_pil_known_good
: it's a list of image types pillow can encode with animation,i couldn't find a way to test this in the program, it also probably needs expandingi made a commit,preview_anim_img_pil_known_good
is also nowpreview_anim_img_pil_anim_supported
the logic to choose image formats happens in get_anim_ext
…ave less of an implication of a permanent conversion
@CyanVoxel |
…nd partially port #357) (#549) * feat: add JXL image thumbnail support Co-Authored-By: BPplays <58504799+bpplays@users.noreply.github.com> * feat: add animated previews for webp and apng Co-Authored-By: BPplays <58504799+bpplays@users.noreply.github.com> --------- Co-authored-by: BPplays <58504799+bpplays@users.noreply.github.com>
I've changed the handling of animated images to include support for more types of animated images.
PR features:
this PR also includes the changes from #344 so feel free to close that one if you prefer this one, though sadly that plugin doesn't seem to support decoding animated jxls
Closes #333