top | item 13871809

Chromium: Add support for Animated PNG

234 points| maxst | 9 years ago |chromium.googlesource.com | reply

140 comments

order
[+] Scaevolus|9 years ago|reply
I've been waiting for this for 9 years :-)

A nice feature of APNG (and GIF) versus the more modern CSS/SVG animations is the CPU efficiency. It's really easy to accidentally waste a ton of battery life by adding a tiny spinning gear to a page.

It varies depending on the browser and whether the GPU is used for compositing, but it's much easier to optimize blitting a rectangle each frame versus blitting a rotation of some complex vector shape on top of the page.

[+] jacobolus|9 years ago|reply
Animated GIFs often burn huge amounts of CPU on my machine. A page full of GIFs can bring a modern computer to its knees. (This is one reason many image sharing sites convert uploated GIFs to proper video files, mp4 or webm or whatever.)

I’ve never quite understood why implementations of GIF viewers in web browsers were so bad. In many cases it seems like they could cache every frame in GPU memory somewhere and very cheaply loop them. Caveat: I haven’t studied this in any detail, and am not an expert on image/video formats.

[+] nwah1|9 years ago|reply
Doesn't this just mean that SVG implementations are poorly optimized, and don't make proper use of the GPU?
[+] erikpukinskis|9 years ago|reply
This is true, if you animate CSS properties that trigger reflows you can seriously harm battery usage.

I try to stick to only animating the transform property, which should perform better than a raster format, since it doesn't require any new data per frame

[+] pjscott|9 years ago|reply
In case anybody is wondering how to roll out server-side support for this with a fallback to GIF: they've added "image/apng" to the Accept header for image requests. It's now "image/webp,image/apng,image/,/*;q=0.8". Sites like Imgur could start serving APNG images today.
[+] MichaelApproved|9 years ago|reply
> Sites like Imgur could start serving APNG images today

I think there'd be a problem when customers copy/paste an image from the site into another application that doesn't support APNG. Seems like a common use-case that would cause a lot of customer confusion.

[+] Sephr|9 years ago|reply
imgur has supported APNG for years.
[+] ksec|9 years ago|reply
APNG started in 2004, I am not sure why it took so long, 13 years before it is landed in Webkit and Blink / Chromium. The fight with MNG only lasted few years. PNG rejected the APNG proposal multiple times ( Why ? )

This is 2017, and when we look forward to 2020, we still dont have anything to replace gif, jpeg, apng, png. With Video we went from MPEG-1, MPEG-2, MPEG-4 ( Divx, Xvid, Rmvb, WMV, VP8 era ) H.264/AV to H.265/HEVC. Our Screen went from Low Res to 4K.

Surely all these browser Vendor can sit down and at least talk about this. How about supporting bpg for a start?

And lastly, I was naively thinking having APNG now would means x years before it is roll out to large number of consumers. But to my surprise even Chrome has a very high usage in China, 60% and growing. China is historically a region of IE6, I remember IE was still 40 - 50% in 2013 or 2014. You could now start to use APNG and soon have 60%+ of your users seeing it. Amazing.

[+] gpvos|9 years ago|reply
> PNG rejected the APNG proposal multiple times ( Why ? )

Because it is not a still image, and therefore should have a different file signature, MIME type, and file name extension. It is simply out of scope for PNG. When designing PNG as a replacement for GIF, they very deliberately and decidedly dropped the animation feature. Implementing APNG as an extension of PNG confuses categories that should not be confused.

[+] mdf|9 years ago|reply
> This is 2017, and when we look forward to 2020, we still dont have anything to replace gif, jpeg, apng, png.

> How about supporting bpg for a start?

There’s FLIF ( http://flif.info/ ) with very promising compression results when compared against WebP, BPG, PNG and lossless JPEG. It also supports animations, which I linked to elsewhere in this thread. Seems like the format is also nearly complete.

[+] EGreg|9 years ago|reply
webp still doesn't show up in iOS Safari!

Too bad, I can't put simple vimeo previews that work on all web browsers as a result.

[+] paxcoder|9 years ago|reply
So Firefox, Safari and now Chrome. Provided image hosting sites start accepting APNG this may finally mean the end of GIF. Why now though?
[+] drdaeman|9 years ago|reply
There's actually a tendency for "GIF" to become a generic term for any small animated pictures, rather than what it used to mean.

I saw it many times that "GIFs" were used to denote what actually were small MPEG4 short clips. Made me cringe internally.

[+] jeroenhd|9 years ago|reply
I assume Google wants to push their own image format (animated webp) instead of supporting an old format nobody has been using for years.

This is good news though; finally we can start to abandon the cruddy old GIF format and move to something more modern.

[+] est|9 years ago|reply
I am wondering what happens to mjpegs.

They are quite common in cheap cams

[+] caio1982|9 years ago|reply
Could anyone more familiar with the field explain why is this better than the now-forgotten-well-i-guess MNG?
[+] mindcrime|9 years ago|reply
Sounds good, but I think they should add MathML support before this. It strikes me as absurd that Chrome doesn't yet support MathML. :-(
[+] usernam|9 years ago|reply
When testing APNG for a local project last year which involved only Firefox, I was trying to save some space and have better color support using APNG.

I found it to be quite buggy, slow, and even occasionally leading to crashes. I switched to webp. APNG was never given enough love, despite being a very useful format.

[+] habitue|9 years ago|reply
Benefits of apng vs. video?
[+] pornel|9 years ago|reply
Hard to find any. It's a primitive format ignoring 20 years of video compression research. It tries to be replacement for GIF by repeating its mistakes: it has very basic inter-frame compression, lacks motion vectors, doesn't guarantee keyframes, RGB-only, and frame decoding isn't parallelizable.

In 8-bit mode it supports even fewer colors than GIF (GIF can combine frames to achieve thousands of colors), and in 24-bit mode it's larger than GIF.

For full-motion video it requires 10x-15x more data than VP9 to be decompressed by the CPU, and there's no hardware acceleration.

https://kornel.ski/efficient-gifs

There's false dichotomy between "animations" and "videos", mostly due to historical reasons and that older codecs (and AWebP) used 4:2:0 subsampling which made them blurry. VP9 supports alpha, 4:4:4 mode, and it's cheaper to decode (it's more complex, but using 10x less data offsets that), so it'd be best to forget that GIF and APNG ever existed.

[+] mdeeks|9 years ago|reply
User experience.

Gifs/apng load and play instantly* and loop. There is no play button to click. No volume button, sliders, etc.

One simple link. Instant load and play.

*assuming good bandwidth

[+] magila|9 years ago|reply
It's much like PNG vs JPEG. Like JPEG, the most common video codecs all use compression based on the discrete cosine transform (DCT). This makes them well suited for most video content which has a lot of continuous tones. APNG is better suited for simple animations with lots of flat shading, where video codecs would generate ugly artifacts. A classic example where APNG would be preferred is the ubiquitous throbber animation used by various applications to indicate that they are busy with some task.
[+] jjuuolkkju|9 years ago|reply
lossless compression and transparency.
[+] mdf|9 years ago|reply
APNG is great, but animated FLIFs[1] would be even better. Looks like many of their former todos have been completed, and from the remaining ones, only three are related to the file format per se. Hopefully these, too, get completed in time. Although, seems like getting support for new file formats in browsers takes time...

[1] http://flif.info/animation.html

[+] Sephr|9 years ago|reply
Why? I thought animated WebP was superior in every aspect.
[+] londons_explore|9 years ago|reply
It is, but WebP has lots of politics involved since it is closely related to WebM, and there are staunch non-supporters of that.

I would hazard a guess this is getting implemented now to try to make WebP look worse.

[+] quasarj|9 years ago|reply
Fucking finally! I've been following this bug for at least 5 years. 5 years ago, when it was first proposed, this could have been a big deal. Not sure these days.. but I sure would love to see GIFs disappear..
[+] tropo|9 years ago|reply
I'd like all formats for both IMG and VIDEO tags.

The gif animations are really video. They play in IMG tags; they are silent and do not have video controls. Put them in VIDEO tags and they ought to get video controls.

Putting a proper video format in an IMG tag should work like an animated gif does: silent, without video controls.

A plain image is a 1-frame video. It should work in a VIDEO tag, just to keep things consistent and orthogonal and all. A 1-frame video is an image; it should work with an IMG tag.

[+] callesgg|9 years ago|reply
What about interframe compression?
[+] Scaevolus|9 years ago|reply
Yes. Each frame can specify a region of the overall image, usually just the bounding box of the changed pixels. There are a few options for retention:

    APNG_DISPOSE_OP_NONE: no disposal is done on this frame before rendering the next; the contents of the output buffer are left as is.
    APNG_DISPOSE_OP_BACKGROUND: the frame's region of the output buffer is to be cleared to fully transparent black before rendering the next frame.
    APNG_DISPOSE_OP_PREVIOUS: the frame's region of the output buffer is to be reverted to the previous contents before rendering the next frame.
[+] wildpeaks|9 years ago|reply
I'd be curious to know why they chose APNG over MNG.
[+] samk117|9 years ago|reply
been waiting for this FOREVER