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

Support for animated gifs #3

Open
joehoyle opened this issue Feb 15, 2016 · 10 comments
Open

Support for animated gifs #3

joehoyle opened this issue Feb 15, 2016 · 10 comments

Comments

@joehoyle
Copy link
Member

Ideally resize, but if that's not possible, just return the original.

@joemcgill
Copy link

The underlying Vips library doesn't support animated gifs (see: https://github.com/jcupitt/libvips/issues/235) but perhaps gifsicle could be used for resizing animated gifs once they've been detected? It's also possible to resize animated GIFs using ImageMagick's coalesce feature but I don't think it's as performant as gifsicle, which is optimized specifically for gifs.

@rmccue
Copy link
Member

rmccue commented Jan 11, 2017

Doesn't appear that gifsicle has native Node support; there's a npm module but that just finds the executable.

Are there any Node libraries that do support GIFs?

@joemcgill
Copy link

I've not yet found one that does gif support natively, so maybe going the ImageMagick/GM route is best until something better is found, since those libraries are available on Lamda.

@joehoyle
Copy link
Member Author

Yeah I had looked into this for a bit, but never found anything. I'd be open to doing it if we had a good node library, right now we just have animated gif detection to not resize animated gifs as that by default will just take the first frame,

@stevegrunwell
Copy link

Might be able to help out here: we ran into a similar problem with a 10up client who wanted to be able to resize gifs while preserving animation. Since Gifsicle doesn't have native PHP bindings, we ended up running Gifsicle on the web server via passthru().

I wrote about the math behind it last summer, which was as much of the code that I could share without stepping on work-for-hire issues. Hopefully that'll help :)

(Thanks to @bswatson for bringing this to my attention)

@rmccue
Copy link
Member

rmccue commented Apr 28, 2017

@stevegrunwell Thanks for the info, super useful! I looked into Gifsicle previously as well, but there's no native Node bindings, and we can't run arbitrary executables on Lambda. :(

That said, maybe it's worth us building those bindings out. Given that most of the complexity is on the Gifsicle side, I imagine the Node connection would be quite simple.

@rmccue
Copy link
Member

rmccue commented Apr 28, 2017

From the libvips author:

libvips supports loading whole GIF images since 8.5, though not GIF save unfortunately

See https://github.com/jcupitt/libvips/issues/620

I'm not super concerned about it tbh, I think it's a lot more effort than it's worth, however it's a nice-to-have if it ever does happen. Leaving the ticket open for #thefuture.

@nathanielks
Copy link
Contributor

It appears it's in development! libvips/libvips#839 (comment)

At the end of the ticket is a user who is able to copy a jpeg to a gif, so maybe worth looking into again?

@nathanielks
Copy link
Contributor

Looking further, it appears Sharp has an issue tracking support: lovell/sharp#1372.

The prebuilt libvips binaries provided by sharp do not include *magick. To take advantage, you will need to compile your own libvips with support for *magick and install it globally before installing sharp.

If I'm reading this right, we just need to compile our own copy of libvips before installing sharp to get this support?

@tareiking
Copy link

Looks like there has been some movement on the feature request upstream with a feature PR at lovell/sharp#2012. What's interesting is that the team with the PR is running this on production, so I suspect it's much closer to being added upstream.

I recall seeing support for this on a recent VIP project as well - so maybe VIP did something custom for their support.

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

No branches or pull requests

6 participants