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

Animated GIF Support for Storage Resize Images? #590

Closed
whitmanc opened this issue Feb 8, 2021 · 9 comments · Fixed by #875
Closed

Animated GIF Support for Storage Resize Images? #590

whitmanc opened this issue Feb 8, 2021 · 9 comments · Fixed by #875

Comments

@whitmanc
Copy link

whitmanc commented Feb 8, 2021

[READ] Step 1: Are you in the right place?

Issues filed here should be about a feature request for a specific extension in this repository. To file a feature request that affects multiple extensions or the Firebase Extensions platform, please reach out to
Firebase support directly.

[REQUIRED] Step 2: Extension name

This feature request is for extension: storage-resize-images

What feature would you like to see?

Animated GIF support

How would you use it?

Similar to how other formats are used.

@whitmanc whitmanc changed the title GIF Support? GIF Support for Storage Resize Images? Feb 8, 2021
@thatfiredev
Copy link
Member

Do you mean animated GIFs?

AFAIK, GIF files are supported, but they're converted to png files after they're resized.
If you do mean animated GIFs, could you describe your use case?

@whitmanc
Copy link
Author

whitmanc commented Feb 8, 2021

@rosariopfernandes Thank you for your response and the correction. Yes, animated GIFs :)

In regard to the use case, we'll be providing a caching layer of sorts for images stored somewhere slow. As part of the service's goal to serve as highly optimized images as possible to the end-users' browsers, we're also aiming to provide these "cached" images in various sizes. A large portion of these images are animated GIFs. It is a tool geared towards developers.

@whitmanc whitmanc changed the title GIF Support for Storage Resize Images? Animated GIF Support for Storage Resize Images? Feb 8, 2021
@jhuleatt
Copy link
Collaborator

jhuleatt commented Feb 9, 2021

It seems like Sharp (the underlying library this extension uses) might support animated gifs (docs). The docs aren't totally clear though, as they say:

Requires libvips compiled with support for ImageMagick or GraphicsMagick. The prebuilt binaries do not include this - see installing a custom libvips.

@jhuleatt
Copy link
Collaborator

jhuleatt commented Feb 9, 2021

@firebase/invertase can you please try an animated gif with the above Sharp options in a Cloud Function and see if it works? If so, seems like an easy thing to support. If not, I don't think we can take this on.

@whitmanc
Copy link
Author

whitmanc commented Feb 9, 2021

@jhuleatt My own interpretation of Sharp's documentation leads me to believe that animated GIF resizing will not work out-of-the-box and would require a node package to make the libvips binary available, or otherwise install libvips on the system. But I could be wrong, it's a little bit vague :)

As an example, here is something that, at first/quick glance, seems similar what I am describing: https://github.com/lovell/sharp-libvips

Also, thanks to everyone for taking the time to check into and discuss it 👏 🙏

@dackers86
Copy link
Member

dackers86 commented Feb 10, 2021

@jhuleatt Can confirm that animated gifs do not currently work. It takes the first frame of the animated image and saves that as a standard image.

As @whitmanc mentioned we will probably need to add further development to add this type of feature.

@dackers86
Copy link
Member

dackers86 commented Feb 17, 2021

As part of an investigation, we have attempted to create an example that could suit our needs.

Using the following as a basic example...

const sharp = require("sharp");

(async () => {
  console.log("Starting >>>");

  const buffer = await sharp("./test.gif", {
    animated: true,
  })
    .resize(60)
    .gif({
      pageHeight: 60,
    })
    .toFile("resized.gif");
})();

Removing resize and 'pageHeight', produce a working animated gif.

image

However, with resize and pageHeight included, the following is generated...

image

This was tested on macOs 10.15.7, ideally we may be able to continue with a proof of concept and more comprehensive instructions on how to add configuration.

Perhaps waiting for the next iteration here lovell/sharp#2275 could be a potential solution

@inglesuniversal
Copy link

Tried latest update (Mar 6th 2021) 0.1.19 and could NOT convert source GIF to thumbnail image and webp as a target image format for thumbs. Sadly did not work

@otopba
Copy link

otopba commented Dec 21, 2021

This is a feature I'm really looking forward to for my project

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

Successfully merging a pull request may close this issue.

6 participants