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

No `pages` metadata for animated gif #1566

Closed
jaubourg opened this Issue Feb 4, 2019 · 7 comments

Comments

Projects
None yet
2 participants
@jaubourg
Copy link
Contributor

jaubourg commented Feb 4, 2019

Maybe I'm doing something wrong but whenever I load an animated gif and do operations on it, I always end up with the first frame transformed and that's it.

In order to determine if this was due to something deep into our code, I looked more closely into the metadata reported by sharp for animated gifs.

From what I understand from the docs, an animated image is supposed to give a pages value that is a number.

If I input an animated monkey found online, I end up with a metadata.pages that's undefined and sharp only acts on the first frame.

Is this by design? Am I missing something?

Also, I saw outputting animated webp was supported but is outputting apng supported too? Could be nice to have a clear support grid somewhere in the docs where this kind of things would be listed. But I know how difficult and time-consuming writing docs can be ;)

@lovell

This comment has been minimized.

Copy link
Owner

lovell commented Feb 5, 2019

Bonjour, it looks like sharp needs to expose libvips' n property on the input so a caller can request all frames (with GIF you have to decode all the frames to find out the frame count and dimensions).

At the command line i see:

$ vipsheader -a small-animated-hear-see-speak-no-evil-moving-monkey.gif | grep page
$ vipsheader -a small-animated-hear-see-speak-no-evil-moving-monkey.gif[n=-1] | grep page
page-height: 157

So it looks like libvips itself also needs to expose the GIF page count too.

@lovell lovell added the bug label Feb 5, 2019

jcupitt added a commit to libvips/libvips that referenced this issue Feb 9, 2019

add n-pages metadata to gifload
gifload was not setting the n-pages metadata item.

n-pages is supposed to be the number of pages in the original file (not
the number of pages libvips loaded), but we don't always know this for
gif, since you have to decode the entire file to count the pages.

As a compromise, set it to the page number of the final page we read.

See lovell/sharp#1566
@jaubourg

This comment has been minimized.

Copy link
Contributor Author

jaubourg commented Feb 12, 2019

I dunno if this is related but I see not pages metadata for the following apng and animated webp image:

@jaubourg

This comment has been minimized.

Copy link
Contributor Author

jaubourg commented Feb 12, 2019

I also get a Error: webp2vips: unable to read pixels when I try and do any action on the webp above except getting metadata. Metadata show it's 400x400 though.

@lovell

This comment has been minimized.

Copy link
Owner

lovell commented Feb 13, 2019

The forthcoming libvips v8.8.0 will add support for animated WebP.

libpng does not support animated PNG.

@jaubourg

This comment has been minimized.

Copy link
Contributor Author

jaubourg commented Feb 13, 2019

Ah that makes sense now. Thanks @lovell :)

@lovell

This comment has been minimized.

Copy link
Owner

lovell commented Mar 17, 2019

Commit 9cc06c8 expose libvips' n parameter as the pages input option to select how many pages to load. This will be in v0.22.0.

@lovell lovell added this to the v0.22.0 milestone Mar 17, 2019

@lovell

This comment has been minimized.

Copy link
Owner

lovell commented Mar 19, 2019

v0.22.0 now available.

@lovell lovell closed this Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.