62

Why are those pesky GIFs still dominating when it comes to animated pictures? I'm sure there are better alternatives nowadays, but why aren't any of them gaining traction?

Fylke
  • 1,753
  • 3
  • 19
  • 30
  • 1
    animated PNG (which is no different than gif and less supported), number of javascript animations: scrolling an image built of sprites, drawing on canvas and other tricks. But I believe that GIF is most compatible and failsafe – venimus Jun 19 '11 at 13:36
  • 1
    It has been almost 9 years since this question was posted. I would like to know the current status of animated (raster) image formats. Is there a "reasonably" supported format now? Are GIFs still our best bet? Should I ask a new question on this topic? – WhatsUp Mar 23 '20 at 22:43
  • @venimus animated PNG support alpha channel, which makes them VERY different from GIF. – Rodrigo Apr 03 '20 at 14:32
  • GIF still dominating is largely due to lack of general consensus about what should be the replacement. There are multiple competing animated image formats, and also some debate on whether we need them at all (leaving animation to video formats). – Youjun Hu Mar 03 '22 at 07:53

7 Answers7

44

Animated png or APNG (http://en.wikipedia.org/wiki/APNG). They can be made in GIMP with the APNG Plug-in But animated Gif's really are the main one out there - flash kinda took over though, but that isn't really an image per se.

Also, other alternatives from the same wikipedia page: The MNG file format is a more powerful alternative to APNG, although is a more complex format and has less web browser support.

The GIF file format has better application and browser support than APNG, but it is limited to 256 colors per frame and supports only 1 bit alpha transparency, by mapping one of the palette colors to transparent.

SVG combined with scripting or SMIL can animate vector graphics and can incorporate raster graphics. (See SVG animation.)

Dynamic graphics created with HTML 5 canvas Object can also be animated.

An alternative method for animations in web pages is to use conventional static images and animate them using JavaScript,[22] Adobe Flash, Microsoft Silverlight, Java or other plugin based technologies.

Christopher
  • 10,409
  • 13
  • 73
  • 97
Nathan
  • 1,483
  • 3
  • 18
  • 41
  • 24
    The story is basically that there are two animated PNG formats: one is officially endorsed but too complex to have been widely implemented (MNG), and one which is simple to implement but is not officially endorsed (APNG). Both have fatal flaws, and it seems the existence of each has prevented the other from fixing those flaws. – Tom Anderson Jun 19 '11 at 13:55
  • 2
    @TomAnderson: What are the fatal flaws of each? – Adi Shavit Mar 22 '15 at 15:00
  • Chromium recently added support for APNG, so even without support added via an extension (which we have had for years), it'll be in Chrome soon. That leaves IE and Edge as the only holdouts. – Corrodias Mar 17 '17 at 02:17
  • 1
    As of 2020 APNG is supported by modern browser engines such as WebKit, Blink, and Gecko. – Evgeni Nabokov Aug 07 '20 at 18:45
15

WebP is an image format employing both lossy and lossless compression. It is currently developed by Google.

Advantages of animated WebP compared to animated GIF

  • WebP supports 24-bit RGB color with an 8-bit alpha channel, compared to GIF's 8-bit color and 1-bit alpha.

  • WebP supports both lossy and lossless compression; in fact, a single animation can combine lossy and lossless frames. GIF only supports lossless compression. WebP's lossy compression techniques are well-suited to animated images created from real-world videos, an increasingly popular source of animated images.

  • WebP requires fewer bytes than GIF1. Animated GIFs converted to lossy WebPs are 64% smaller, while lossless WebPs are 19% smaller. This is especially important on mobile networks.

  • WebP takes less time to decode in the presence of seeking. In Blink, scrolling or changing tabs can hide and show images, resulting in animations being paused and then skipped forward to a different point. Excessive CPU usage that results in animations dropping frames can also require the decoder to seek forward in the animation. In these scenarios, animated WebP takes 0.57x as much total decode time2 as GIF, resulting in less jank during scrolling and faster recovery from CPU utilization spikes.

Disadvantages of animated WebP compared to animated GIF

  • In the absence of seeking, straight-line decoding of WebP is more CPU-intensive than GIF. Lossy WebP takes 2.2x as much decode time as GIF, while lossless WebP takes 1.5x as much.

  • WebP support is not nearly as widespread as GIF support, which is effectively universal.

  • Adding WebP support to browsers increases the code footprint and attack surface. In Blink this is approximately 1500 additional lines of code (including the WebP demux library and Blink-side WebP image decoder). Note that this problem could be reduced in the future if WebP and WebM share more common decoding code, or if WebP's capabilities are subsumed in WebM's.

https://developers.google.com/speed/webp

Vladimir
  • 289
  • 3
  • 6
7

I would like to propose the use of video for animated pictures. There is now broad support for the video tag in HTML5 and nearly equal support for MPEG4.

<video autoplay loop src="sample.mp4">

With the autoplay and loop attributes, it is easy to replicate the behavior of an animated GIF.

I will concede that transparency in video is still an issue.

Community
  • 1
  • 1
Keith Shaw
  • 624
  • 6
  • 7
2

As answered by Nathan and others earlier, there are many ways to animate graphic.

Personally I prefer

(1) creating the graphic in Illustrator or Inkscape etc.

(2) save the graphic in .SVG format

(3) embedded the SVG code (ie. everything between and ) in your web page and

(4) use snap.svg (javascript libary) to animate the embedded svg graphic. Most modern browser supports SVG

gprathour
  • 14,813
  • 5
  • 66
  • 90
2

With jquery, I am able to rotate 6 jpgs of a lenticular sequence back and forth to attain the same result of an animated gif; for example, http://www.vicgi.com. The total file size for 6 image is only 233KB. Had this been an animated gif there will be 11 frames and the file could have been over 1MB. Not to mention the number of colors is limited to 256 for a GIF.

HTML

<!-- Reserve a div for showing the images with id=banner -->
<div class="row">
    <img id="banner" src="images/first_image.jpg" class="img-responsive">
</div>

Javascript: Add this code before end of body tag, assume you have linked to jquery cdn or download.

var images = [
"first_image.jpg",
"second_image.jpg",
"third_image.jpg",
"forth_image.jpg",
"fifth_image.jpg",
"sixth_image.jpg",
"fifth_image.jpg",
"forth_image.jpg",
"third_image.jpg",
"second_image.jpg",
];   // add the images if necessary

numImages = images.length,
index = 1;  // start from the second image because first image is already in the HTML

function cycleImages() {
    image = "images/" + images[index];   // assume all the images are store in the images sub-directory
    $("#banner").attr("src", image);     // set the src attribute of the <img tag to the image to be shown
    index++;                             // advanced to the next image
    if (index == numImages) index = 0;   // recycle to the first image
}

$(function() {                          // start the rotation when document is ready
    setInterval("cycleImages()", 800)
});
1

This was obviously quite a long time ago, but times change and .webm seems to be a good contender.

In short, it is a media format that is meant to be royalty free. It would be used with the HTML5 video tag (see the answer from @KeithShaw) and would require a browser that supports the appropriate codec. However, YouTube is one of the adopters, as well as, a number of other industries that I will not mention here.

This is the project's site: WebM Project

JasonWilczak
  • 2,303
  • 2
  • 21
  • 37
0

MNG format is a PNG-like format for animations, but it doesn't seem to have gained much popularity. So it's just a question of adoption - as animated GIFs work fine (and are free of former patent restrictions), why not use them? Why repair what's not broken?

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
  • 21
    Because they're limited to 256 colors without alpha transparency. – SLaks Jun 19 '11 at 13:37
  • @SLaks don't see how "limited" becomes "broken". And note "animated GIFs work fine". They do for most people. For those who are not satisfied, Flash works in most cases. – Eugene Mayevski 'Callback Jun 19 '11 at 15:34
  • 9
    It's the lack of alpha transparency that's broken - it means you can't use a single animated GIF across all backgrounds, because you have to composite separately with each background colour to make it look okay. – Tom Anderson Jun 19 '11 at 19:11