Image formats Understanding JPEG Image Formats How to Convert PDF to JPG in .NET Image Conversion to Base64 in Python: A Comprehensive Guide How to convert PDF to JPG with Python Raster vs Vector: Navigating the Digital Image Landscape What Is a PNG Image and How to Convert It? Comprehensive Guide on Converting PDF to JPG on Android Converting PDF to JPG Using Java Ways to Convert WebP to PNG Converting JPG to GIF: Creating Aesthetically Beautiful Website Pages How to Convert MP4 to PNG to Enhance Accessibility and Unmatched Quality Convert PNG to SVG PDF to TIFF Made Easy: Top Tools and Techniques SVG Format: Features, Common Uses, and Pros/Cons You Should Know Convert Image to PDF – All the Options Complete Guide On Converting TIFF To JPG Converting Images From AVIF To JPG Converting Images From TIFF To PNG Everything You Need To Know About AVIF To PNG Conversion Everything You Need To Know About WebP To SVG Conversion How to Convert Images From WebM To PNG A Developer’s Guide to SVG Optimization The Developer’s Guide to PNG Formats: Maximizing Impact with PNG-8 and PNG-24 Understanding PSD: Complete Guide How to Convert WebP to JPG: A Comprehensive Guide How to Convert HEIC to JPG: A Comprehensive Guide Should You Still Use BMP Format? Use Cases and Pros/Cons MXF Format: Key Features, Use Cases and Pros/Cons Indesign Format: Features, Pros/Cons and Best Practices HEIF Format: Meet the The Next Evolution of JPEG glTF: Features, Applications, and 5 Essential Best Practices ICO Format: Origins, Common Uses, and Important Pros/Cons GLB Format: How It Works, Use Cases, and Pros/Cons You Should Know DNG Format: How It Works and Pros/Cons to Know About EPS Format: History, How it Works, and Pros/Cons You Should Know SVG Format: Features, Common Uses, and Pros/Cons You Should Know EPS vs SVG: 4 Key Differences and How to Choose AVIF vs. WebP: 4 Key Differences and How to Choose DNG vs RAW: Pros, Cons, Key Differences, and How to Choose AVIF Format: A Next-Gen Image Format to Rule them All? The TGA Format Is Alive and Kicking: Why and When to Use It USDZ Format: How It Works, Use Cases, and Pros/Cons BMP vs PNG: 4 Key Differences and How to Choose HEIF vs JPEG: 4 Key Differences and How to Choose SVG vs PNG: 4 Key Differences and How to Choose Automatically Change Format To JPG How to Convert PNG to JPG? All the Options Converting PNG to TIF: Options and Best Practices Convert JPG to TIFF WebP Format: Technology, Pros & Cons, and Alternatives GIF Format: Past, Present, and Future

GIF Format: Past, Present, and Future

gif format

What Is GIF Format?

The Graphics Interchange Format (GIF) is a compressed image format, originally developed by Steve Wilhite in 1987. It uses the Lempel-Ziv-Welch (LZW) compression algorithm, a lossless compression method (meaning it does not degrade image quality).

GIFs generally allow up to 8 bits per pixel per image and up to 256 colors. By contrast, the more advanced JPEG format can display up to 16 million colors, very close to the limit of the human eye.

History of the GIF File

GIF was a major development in the early days of the Internet, because bandwidth and device capabilities were very limited. GIF compression made it possible to serve image content over the Internet with acceptable performance.

In the early 1990s, the GIF89a spec added the ability to combine many images or frames into a single file and display them in sequence to create an animated clip or short video. This turned GIF into a video format. Like in the original GIF format, colors are limited to a maximum of 256 per frame. In 1995 this capability was added to the Netscape Navigator browser, leading to widespread use of compressed animated GIFs.

Related content: Read our guide to video frame rate.

Today GIFs are still widely used. GIPHY, an online database and search engine for GIFs, has over 250 million active users and was purchased by Facebook for an estimated $400 million. Whatsapp supports the use of animated GIFs, and over 70 million GIFs are sent via the WhatApp application daily.

In this article:

GIF File Format: How Does GIF Work

GIF files describe a logical screen with a graphical area of a fixed size. This screen may contain one, multiple, or no images. A GIF file may contain a single image filling the whole logical screen, or it may divide the screen into separate smaller images. These images can function as animation frames in animated GIF files, but they don’t have to fill the whole logical screen.

A GIF file starts with a header with a fixed length – for example, GIF87a or GIF89a. It provides the file version and logical screen descriptor (also with a fixed length) specifying logical screen dimensions in pixels and additional characteristics. The descriptor can specify if there is a Global Color Table (GCT), followed by the size description if present.

The GIF file then splits into various segments introduced with a single-byte sentinel:

  • The image – starts with 0x2C and an ASCII comma
  • The extension block – starts with 0x21 and an ASCII exclamation point
  • The trailer – has a 1-byte value of 0x3B and an ASCII semicolon (this should be the file’s last byte)

The image component begins with a fixed-length image descriptor that specifies if a local color table is present (and its size). Following is the image data, with a single byte providing the unencoded symbol width (in bits) – there must be minimum 2-bit width. Next is a linked list with sub-blocks defining the data encoded by LZW.

The extension blocks extend the 87a definition using a pre-defined mechanism from the 87a spec. Each block consists of a sentinel and another byte specifying the extension type, followed by a linked list with sub-blocks for the extension data. An extension block that modifies an image must precede the file segment containing the relevant image. For example, graphic control extensions can specify optional animation delay times and transparent background colors, but they must be next to the affected image.

The extension blocks and image data use linked lists consisting of several sub-blocks. Every sub-block starts with a single byte specifying the number of data bytes following it within the sub-block (up to 255). Each sub-block series ends with an empty (0-byte) sub-block.

This file structure enables parsing even when a decoder does not understand some parts of the file. GIFs marked with an 87a can include extension blocks – the idea is for the decoder to read and display files while ignoring features in the extensions it doesn’t understand.

What Are GIFs Used For?

GIFs have a variety of uses, both personal and professional:

  • Marketing—GIFs provide a simple, lightweight mechanism for promoting products and services. GIF images and animations can be used to share brand images, create banner ads, and even show a quick animated preview of how products work and their benefits.
  • Information sharing—GIFs can be used to deliver graphs and charts with engaging animation effects, to help users better understand complex information. Animated GIFs can be used to create step-by-step how-to guides that are lightweight and can be viewed on any device.
  • Social media engagement—GIFs are used to create animated responses to social media discussions and add humor to blog posts, allowing brands to improve customer relationships and create a better connection with digital-first consumers.

GIF Format: Pros and Cons

Benefits of GIFs:

  • Small file size—GIFs provide a relatively small file size compared to other image formats. They can be downloaded faster without sacrificing quality, and are especially suitable for environments with limited bandwidth and computing resources.
  • Transparent background—both regular GIFs and animated GIFs support transparent backgrounds. This can let you combine GIF images with background colors, images, or animations, to create innovative web designs.
  • Easy to use animation—animated GIFs are easy to create and easy to consume on almost any device. This can help creators and website owners deliver a better experience to their audiences.

Shortcomings of GIFs:

  • Limited color scheme—both GIFs and animated GIFs support only a 256-color palette, making it look less attractive and detailed than other image formats. In some cases, the image may appear slightly jagged or pixelated.
  • Cannot be edited—an animated GIF has the frames and animation encoded in the actual file, and cannot be edited. To modify an animated GIF, you must recreate it from the source data. Other images and animation formats make it possible to edit the image or video without recreating it.
  • Heavyweight compared to other animation formats—while animated GIFs have advantages, they have a heavier file size than other optimized video formats. Adding a large number of animated GIFs to web pages can make them load slower. It is a best practice to use HTML5 video instead of animated GIF to improve performance.

“Video

How to Open GIF Files

On Mac

Opening GIF files on a Mac is easy with built-in applications that support this file format. Here are the steps:

  • Preview: The quickest way to open a GIF file on a Mac is by using the Preview application. Simply double-click the GIF file, and it will open in Preview by default. If it doesn’t open with Preview, right-click the file, select “Open With,” and choose “Preview.”
  • Safari: You can also open GIF files in a web browser like Safari. Drag and drop the GIF file into an open Safari window or use the “File” menu to select “Open File” and navigate to your GIF.
  • Photos: If you want to manage your GIFs alongside your other images, you can import them into the Photos app. Open Photos, go to “File” > “Import,” and select the GIF file you want to view.
  • Third-Party Applications: For more advanced features, consider third-party applications like Adobe Photoshop or GIMP, which provide extensive tools for viewing and editing GIF files.

On Windows

Opening GIF files on a Windows computer is equally simple, thanks to various built-in and third-party options:

  • Photos App: The default Photos app on Windows 10 and 11 can easily open GIF files. Double-click the GIF file, and it should open in the Photos app. If not, right-click the file, choose “Open With,” and select “Photos.”
  • Web Browsers: Similar to macOS, you can use web browsers like Microsoft Edge, Google Chrome, or Firefox to open GIF files. Drag and drop the GIF into an open browser window, or use the “Ctrl + O” shortcut to open the file.
  • Windows Media Player: Although primarily used for video and music, Windows Media Player can also open GIF files. Right-click the GIF file, select “Open With,” and choose “Windows Media Player.”
  • Third-Party Applications: For advanced viewing and editing, third-party applications such as IrfanView, Paint.NET, or Adobe Photoshop offer more functionality. Download and install your preferred software, then open the GIF file through the application’s interface.

These steps should help you open and view GIF files easily, regardless of whether you’re using a Mac or a Windows PC.

Automatically Converting GIF into Modern Image Formats with Cloudinary

GIF is a commonly used format, but it has inefficient compression, which means larger file size and slower page load times. Wouldn’t it be great if you could keep your old GIF images, but serve them to users in next-generation formats that are a fraction of the size?

Since different browsers support different image formats, the best solution to optimize delivery time and save bandwidth is to deliver the best format according to the browser used by each of your visitors. This is exactly what Cloudinary does with a feature called “f_auto”.

Cloudinary is a cloud-based image management platform. You can upload GIF or any other images (and videos too for that matter) to Cloudinary (signup is free). From that point onwards, you can serve a GIF image using a dynamic URL. When you use the “f_auto” parameter in the URL, it will automatically convert the image into the best possible format for the user’s current browser.

How does dynamic format conversion (f_auto) work?

f_auto performs automatic format selection based on the requesting browser – for example, the image could be delivered as AVIF, WebP or JPEG-2000. If the original image is an animated GIF, f_auto will automatically convert it into animated WebP, which is much lighter and faster.

If a browser does not support any of the optimized formats that f_auto is enabled to return, then the image is delivered in the format specified by the file extension.

Live demo of automated conversion from GIF to modern file formats

Take the example of the scaled shoes image below. The source format of GIF (98 KB) is quite heavy. By using f_auto, we can deliver this image as an AVIF (14.6 KB), WebP (16.1 KB) or JPEG-2000 (21.0 KB) to the client browser.

In fact, the image below has already loaded on your browser as one of these modern formats and not as GIF (assuming you are running a current browser).

https://res.cloudinary.com/demo/image/upload/c_scale,w_500/f_auto/docs/shoes.gif

Next steps:

QUICK TIPS
Nadin Indre
Cloudinary Logo Nadin Indre

In my experience, here are tips that can help you better manage GIFs in modern workflows:

  1. Use optimized GIF export settings for web delivery When exporting GIFs, reduce the number of frames or frame rate without sacrificing fluidity. Removing unnecessary frames or lowering the frame rate from 30 fps to 15 fps can drastically reduce file sizes.
  2. Take advantage of hybrid GIF-to-video formats Convert large animated GIFs to modern video formats like MP4 or WebM, which offer better compression and can be embedded seamlessly with HTML5. These formats retain quality while loading much faster on web pages.
  3. Implement CSS or SVG for lightweight animations Instead of using animated GIFs for simple transitions or logos, use CSS or SVG for vector-based animations. This reduces file size and increases rendering performance, especially for interactive web elements.
  4. Layer transparency with precision Use GIFs with alpha transparency only when necessary. Otherwise, WebP or PNG formats handle transparency more efficiently and with better color depth, improving visual fidelity on modern screens.
  5. Compress static GIFs with lossless tools Tools like ImageMagick or Gifsicle can reduce the file size of static GIFs without degrading quality. Use lossless compression techniques to reduce bandwidth usage while retaining visual sharpness.
  6. Leverage variable playback speeds Adjust the playback speed of animated GIFs to optimize viewer experience. Shortening the animation loop or adjusting the frame delay can make a GIF appear smoother and reduce file size.
  7. Utilize Cloudinary’s format conversion for optimization When serving animated GIFs on modern websites, use Cloudinary’s f_auto parameter to convert GIFs into lighter formats like animated WebP or AVIF. This significantly reduces bandwidth costs and improves page load times.
  8. Consider color palette reduction for lighter GIFs Reduce the number of colors in a GIF’s palette if the full 256-color range isn’t necessary. This can reduce file size without noticeably affecting the image quality, especially for simple animations or graphics.
  9. Test GIF performance across devices and browsers GIFs can display differently on various browsers or devices. Test the playback, color accuracy, and transparency handling across platforms to ensure consistent visual quality.
  10. Explore HTML5 canvas for advanced animation control For interactive or high-performance animations, use the HTML5 canvas element instead of GIFs. It offers better control over animations, reduces memory usage, and can be dynamically updated without reloading the entire image.
Last updated: Sep 4, 2024