-
Notifications
You must be signed in to change notification settings - Fork 204
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
Animated GIF support #246
Animated GIF support #246
Conversation
Elad-Laufer
commented
Jan 13, 2022
•
edited
Loading
edited
- Export native of GIF
- Support animated images resize
- Support animated images rotate
- Load from file with import options
- export GIF - resize animated images - export animated images
- when building ImageMetadata add all the props
- Add imageRef.Grid() func - rename ...pages... functions to something more reasonable
- fix 270 rotation of multi-page images - Pages() instead of GetPages() is more Go like - Orientation() instead of GetOrientation() is more Go like
Resolve conflicts? |
# Conflicts: # vips/image.go
done |
I'm super excited for this to land! Right now I have some "if-gif" code to fall back on the builtin image package when dealing with gif images that I would love to delete. |
Awesome! @davidbyttow could we cut a new release including this commit? |
Sweet I'll try it out later today. If I recall before, gifs would break when I tried to resize them. As a result I had to store gifs in a separate S3 bucket with a separate CloudFront bucket which had my Lambda@Edge function disabled. If gif resizing is working now, I'd be excited to unify gifs with the rest of the images on my server. |
@davidbyttow @Elad-Laufer So I just pulled down this version and tested it out but I'm still seeing the same issue I saw before. If I import a GIF from a file and then export it back to a file, it only seems to write the first frame of the GIF. I'm not sure if this is still broken or if I'm "holding it wrong", but I've attached the images I used to test:
I'm importing the image from a file handle like so:
And then I'm exporting it this way:
And writing the bytes back to the new file. Is this supposed to be working? Or is there another way to import / export GIFs I should be using? UPDATE: I found the test case that was added and saw that you must explicitly set the number of pages to -1 when importing a GIF. Once I did that it worked.
That said, I believe defaulting to only loading the first frame of a GIF is a bad UX. I'd advocate for making the default value be -1 so that importing and exporting an image with the default parameters would round trip. |
I agree, but that would change the current behavior and break backwards compatibility in an unexpected way as it will compile just fine and will behave differently. For example, when converting an animated image to a format that does not support animation such as JPEG, if more than one page is loaded the exported image will be the entire roll and not a single frame (which defaults to the first one). This is probably another good point to consider in #248. |
There could be |