-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: support for animated WEBP & GIF #2012
Conversation
Re: imagemagick support
Use this as base for image of docker container with your application for imagemagic-enabled libvips. |
Thanks for this PR Tomáš, much appreciated, I expect to have some time to take a proper look at this during the next week or so. |
@deftomat There's now a pre-release 8.9.0-rc4 version of the prebuilt libvips binaries available to help with this PR. You might also want to rebase against the wit branch as it has a couple of other changes required for libvips v8.9.x. This should allow you to fix up the linting errors and test failures. |
just to jump in on this, this seems to rebase pretty easily with the wit branch. Linting and tests pass apart from three.
not sure if the tests need amending, or if, in an environment without libvips + imagemagick, it needs a fallback. |
This is super exciting! Would this change require ImageMagick for everyone using Sharp, or just people who want WebP / GIF? |
@christianbundy Please see #1372 (comment)
|
@lovell is there plans for creating a version of sharp that includes prebuild libvips with *magick support? maybe have a flag during installation or something like that? since we use Sharp in a production application running in windows, and using a globally installed version of libvips is not supported in windows, this means that we will never be able to use these features. |
@elndro85 No, but all the tools to build your own are open source - see https://github.com/lovell/sharp-libvips |
@lovell in order to get this built and working with magick support for I did that and also attempted a rebase of this branch on top of your |
What about APNG ? |
@kapouer libpng, as used by libvips, does not support APNG. |
@lovell looks like your |
The latest version of sharp depends on (and provides a prebuilt) libvips v8.9.0 as required by the changes in this PR, so yes, it can now be rebased against the |
AWESOME! 🥳 Sorry to everyone which is waiting for this. I didn't have a much time lately but I will try to finish it this weekend. |
How about this weekend? |
How about next one? |
@deftomat The internals of sharp have been migrated to N-API hence there are now a few conflicts in this PR. As always, I'm happy to keep PRs open for as long as necessary; please ignore any implied time pressure in comments. I'd also be happy to accept an alternative PR that focuses on WebP. Avoiding the *magick dependency might make for a simpler method by which to introduce this feature initially. |
Even if we can get WebP ones without Magick support it will still be good. |
Ok, let's finish this PR. We need to upgrade our fork to the latest Sharp anyway. |
Please let me know how can I help you in this. I am ready to offer my axe. |
I got the following test failures:
I'm not sure how we want to test GIF features as ImageMagick support is not included by default. Also, I'm not sure what the 4th failure means. |
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.
This is looking so much better, thank you very much - I've left a few comments inline.
I've created #2275 with some thoughts on possible future improvements to handling animated/multipage images beyond this PR. |
@deftomat I'm preparing v0.26.0 for release. hopefully in the next few days. Are you able to take a look at the last couple of remaining comments? I might have a chance to address them myself, otherwise this can wait until a future v0.26.x release. |
@lovell I will try this weekend |
@lovell Comments resolved! |
@deftomat Marvellous, thank you very much for persisting with this Tomáš. |
Commit 4beae0d adds // Convert an animated GIF to an animated WebP (available from v0.26.0)
sharp('in.gif', { animated: true }).toFile('out.webp'); |
Sounds good! |
v0.26.0 now available, enjoy! |
@lovell may it be used with My code sharp(buffer, { animated: true })
.resize({
height: 100,
width: 100,
})
.toBuffer(); |
I'm an idiot and don't know what I'm doing, but would like to use this feature on AWS Lambda – can anyone help with steps to compile libvips + *magick so it can be used there? |
@davekiss Hi, we have our custom You need to add something like the following before mkdir ${DEPS}/libtool
curl -Ls http://ftpmirror.gnu.org/libtool/libtool-${VERSION_LIBTOOL}.tar.gz | tar xzC ${DEPS}/libtool --strip-components=1
cd ${DEPS}/libtool
./configure --host=${CHOST} --prefix=${TARGET} --enable-shared --disable-static --disable-dependency-tracking
make install-strip
mkdir ${DEPS}/imagemagick
cd ${DEPS}/imagemagick
curl -O https://imagemagick.org/download/ImageMagick.tar.gz
tar xzf ImageMagick.tar.gz
rm ImageMagick.tar.gz
cd */.
./configure \
--host=${CHOST} \
--prefix=${TARGET} \
--enable-shared \
--disable-static \
--with-modules \
--without-bzlib \
--without-dps \
--without-freetype \
--without-jbig \
--without-jpeg \
--without-jp2 \
--without-lcms \
--without-lzma \
--without-png \
--without-tiff \
--without-wmf \
--without-xml \
--without-zlib \
--without-perl \
--without-x \
--without-magick-plus-plus \
--enable-delegate-build \
--disable-dependency-tracking \
--disable-docs \
--disable-openmp \
--disable-installed
make install-strip And then use Not entirely sure if that is enough as we customised it a while ago but it should be enough. Then, just follow https://sharp.pixelplumbing.com/install#custom-prebuilt-binaries to build it in AWS Lambda docker container, deploy sharp as layer and require it directly from |
@davekiss It's the first comment. #2012 (comment) |
How would I stitch together images and output an animated gif? Do I need to create the buffer with some other tool? Or can I use sharp to incrementally add the images, maybe even as a stream? To be more specific, can I do something like this:
Or should I be using compose? On a side note, compiling imagemagick with the above instructions didn't work for me. I'm getting a format not detected error from imagemagick for 'gif'. Do I need to add LDFLAGS or something like that? |
Does anyone have a sample code for animated webp resizing? I have a workable piece of code for gif:
but webp doesn't work
|
Requires
libvips 8.9
New features:
Please keep in mind that to create a GIF file, libvips must be compiled with imageMagick support (which could be a real pain 😞 )