.fw files.wiki
GIF

GIF Files

Graphics Interchange Format

A GIF file is a palette-based bitmap image format widely used for simple web graphics and short looping animations.

Graphics Interchange Format (GIF87a/GIF89a)

Developer
CompuServe
Category
Images
MIME type
image/gif
Format
Binary
Magic bytes
47 49 46 38 37 61 / 47 49 46 38 39 61
First released
1987
Latest version
GIF89a
Open standard
Yes

Open a .GIF file online

Reading file…

What is a .GIF file?

.GIF file usually consists of Graphics Interchange Format image files - a raster-based, binary image format which was developed in 1987 by CompuServe as means for sharing digital images online. Since GIF stores an indexed image, each of its frames can include a limited amount of up to 256 colors plus 1-bit transparency. This extension supports files with still images as well as multi-frame animations, which is the reason behind presence of GIFs in memes, messaging apps, reaction images, manuals and web application interfaces.

Two versions have been described: GIF87a and GIF89a. They both start with an ASCII signature (usually found on the byte offset number 0) called GIF87a or GIF89a and this information represents one of the most effective ways to identify real GIF files. GIF89a included blocks of Graphic Control Extension as well as animation options that made looping animations in browsers possible due to textual and application extensions.

It is quite easy to spot .GIF extension being recognized by almost any browser or operating system as an image/gif file. This format can be found while viewing website pages, when taking screen or video shots, downloading and uploading files via chats and embedding in the website using IMG tags. There is no popular modern file format that would use such extension, so file not starting with GIF87a or GIF89a is certainly not a true gif-file.

How to open a .GIF file

Open a .GIF file on Windows

  1. 1 Go to the folder with your file in File Explorer. Usually, downloaded files end up in Downloads.
  2. 2 Double-click your .GIF file if you have an app for .gif files on your computer. In case it does not open, move on to step three.
  3. 3 Right-click your .GIF file -> select Open with -> Choose another app.
  4. 4 Choose Microsoft Photos in the list (Windows 11: choose Always). For Windows 10 -> put a check on "Always use this app to open .gif files" and click OK.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Windows

Open a .GIF file on macOS

  1. 1 In the Finder app, locate your .GIF file.
  2. 2 Just double-click your .GIF file in order to automatically launch the program which is connected with it.
  3. 3 Need another app on your Mac? Control-click the file (or right-click with a mouse). In the pop-up menu select Open With -> Preview.
  4. 4 If it isn't in the list, choose Other… and find the application manually.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for macOS

Open a .GIF file on Linux

  1. 1 Launch your file manager. Depending on the desktop it may be named Files (GNOME), Dolphin (KDE Plasma), Nemo (Cinnamon) or Thunar (Xfce).
  2. 2 Double-click the file.
  3. 3 Or choose another program by right-clicking the file -> Open With -> Google Chrome.
  4. 4 Install Google Chrome (if it is not installed on your computer) from the software centre, repository or Flathub.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Linux

Open a .GIF file on Android

  1. 1 Launch Files or another file management app.
  2. 2 In Downloads, find the .GIF file and open it by tapping.
  3. 3 A list of apps capable of opening the file will be shown. Tap Google Chrome and press Always to permanently connect the file type with this app.
  4. 4 No apps able to open this file? Download Google Chrome from the Google Play Store.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Android

Open a .GIF file on iPhone / iPad

  1. 1 Use the Files app and go to On My iPhone, iCloud Drive or Downloads.
  2. 2 Tap the .GIF file you want to open.
  3. 3 If the file can be opened by a built-in iOS app (supported format), it opens automatically.
  4. 4 Touch and hold the file to get the context menu -> choose Share -> select Safari from the list of apps.
  5. 5 If there is no such option, download the app first from the App Store and then tap the document again.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for iPhone / iPad

Open a .GIF file online

  1. 1 Move to the online viewer at the top of this page.
  2. 2 Drag the file there or select it, and its contents will appear in your browser tab. The file is not uploaded.

Still not opening? See common problems and fixes, or view it in your browser.

Programs for Online

More details about opening .GIF files

Native browser-based support for GIFs exists in Chrome, Firefox, Safari, Edge on Windows OS, macOS, Android, iOS. In these browsers, animations play as soon as the gif-file gets loaded up by the browser. When viewing GIFs on Windows 10 OS, users can resort to using IrfanView or XnView MP or the browser, but using a browser is often the simplest way to view animations. On the other hand, it is possible to open most GIF-files with the aid of Microsoft Photos and then use a browser, GIMP, ImageMagick, Photoshop when frame-level modifications are required.

For preview, basic modification and exporting operations, on macOS operating system users can resort to Preview and use Safari browser to view gif-file; for actual work involving editing a GIF, then it makes sense to use one of following programs - GIMP, Photoshop or XnView MP. For Linux, desktop environment applications usually provide GIF-support; browser has built-in support of these objects too. The most versatile tools for editing gifs on Linux are GIMP, ImageMagick, FFmpeg and XnView MP.

GIFs display natively in various browser applications, gallery, Photos on both Android and iOS systems; they play within various messenger applications, GIPHY applications and many web social network applications (which might translate these images to video objects). There exist online services for doing edits (trimming, resizing, converting) and making captions like ezgif.com and other online GIPHY tools without necessity of software installation.

In case where GIF doesn't open via double click in viewer, check if .gif filename extension is used, the GIF's signature consists of first six bytes are GIF87a or GIF89a, make default app to be browser or image-viewer. In case of professional edit, open your animation file in Photoshop or GIMP.

Technical details

The GIF Format is a binary encoding. Each GIF file starts with 6 ASCII bytes 'GIF87a' or 'GIF89a', which look like 47 49 46 38 37 61 / 47 49 46 38 39 61 in hexadecimal code at offset number 0. After that there is information about logical screen - its width & height and flags indicating whether there will be a global color table (palette), how many bits used for colors, should the colors be sorted, color-indexed background used (which one), and so on. It means that color data are indexed, and that the palette used for any image consists of 24-bit rgb-coded colors; although the amount of such colors is not bigger than 256 because an image frame can refer only to so many color entries from palette.

The image data are encoded using LZW-compression and consist of sub-blocks each of max 255 bytes long, after them there follows empty sub-block and ends by 1 byte of trailer 3B. Incomplete downloaded files usually don't have this trailer (as well as last sub-block), sometimes the file stops within an image sub-block.

In GIF89a, the extension blocks introduced are the Graphic Control Extension, Comment Extension, Plain Text Extension, and Application Extension. The latter is commonly called the Netscape-style Application Extension.

Animated GIFs are created by using many image frames described with Image Descriptors and Graphic Control Extensions - last of which indicate how long (how many hundredths of a second is a timeout before next) each frame of animation should live, which color should represent transparent one in the palette and what happens on disposal (disappearing).

It has to be mentioned that GIF Format supports binary transparency but doesn't offer either alpha-blending (transparency channel for each pixel) or core color-profile support, as well. It has registered MIME type of "image/gif", while its metadata support looks poor comparing to PNG, JPEG, WebP formats and stills sizes usually vary in range from hundreds to hundreds of kilobytes, animations can weigh more than several millions bytes in unoptimized versions.

How to convert .GIF files

Convert your still GIF to PNG if losslessness or increased palette colors are needed for output. It’s quite possible using ImageMagick command of magick input.gif output.png and choosing one image with input.gif[0] for preventing generation PNG files of each of animated GIF images. For the case you would like to have animation in the form of the MP4 file (website, presentation or any social media) use H.264 codec which generates smaller-sized videos than GIFs - use command of ffmpeg -i input.gif -movflags +faststart -pix_fmt yuv420p output.mp4. But there is no problem to make an animated WebP or animated APNG (for better animation, more color support), magick command should look like as magick input.gif -loop 0 output.webp or ffmpeg -i input.gif -plays 0 output.apng and testing in the target application after.

For a photographic first frame, or creating a thumbnail use only format of JPEG - it removes all the animation properties from your image: magick input.gif[0] -background white -alpha remove -alpha off output.jpg. Frame delays, disposal and many other parameters, related to your frame, will be better tuned via GIMP or Adobe Photoshop tools and not with FFmpeg tools. For fast processing (resizing, adjusting speed or creating thumbnail) you need the help of a specialized website as ezgif.com. Don’t forget when you convert a video file into your animated GIF, that its frame rate or number of colors will be changed and its size.

Convert toToolCommand / note
PNG ImageMagick magick input.gif output.png For animated GIFs this writes one PNG per frame unless a single frame is selected, e.g. input.gif[0]. Transparency and exact palette colors are preserved well.
WebP ImageMagick magick input.gif -loop 0 output.webp Animated WebP usually gives smaller files and better color than GIF, but very old software may not open it.
MP4 FFmpeg ffmpeg -i input.gif -movflags +faststart -pix_fmt yuv420p output.mp4 Best for social media and video players; GIF loop metadata and transparency are lost.
APNG FFmpeg ffmpeg -i input.gif -plays 0 output.apng Keeps animation in a PNG-based format with better color/transparency support, but APNG support is not universal in older apps.
JPEG ImageMagick magick input.gif[0] -background white -alpha remove -alpha off output.jpg Suitable for a still image; animation and transparency are lost and JPEG compression may add artifacts.
Sprite sheet PNG FFmpeg ffmpeg -i input.gif -vf tile=5x5 frames.png Useful for game/UI assets or inspection; timing and loop information are not retained.

Common problems and fixes

"The picture is looking grainy," and "colors are incorrect" mean, most likely, that your picture is reduced to 256 colors, and the dithering process is applied badly. Remake your GIF to have more accurate colors using Photoshop, GIMP, ImageMagick or FFmpeg; you can convert GIF also to the formats of PNG, WebP or MP4.

If your viewer displays the animation "does not work" most likely it shows you the very first frame which usually has 0 index in animated GIF. Open your GIF in the internet browser Chrome or Firefox or Safari, or some other application which can handle animated GIF: Photoshop, GIMP, ImageMagick, FFmpeg, IrfanView or XnView MP.

"Invalid GIF signature" and messages like "not a GIF file" show that the bytes of the signature GIF87a or GIF89a is absent on bytes 0-5 of a file. Either rename your file with proper .gif ending after the check of its signature or take another file.

"Missing trailer", "truncated file, unexpected end of file". It is possible either you haven't completely received that file and you haven't all the frames, or LZW compression data block doesn't contain any terminator and subblocks were not received completely. Try re-downloading of a file, restore the file using its version or perform recovery operation using ImageMagick or FFmpeg.

If in the settings of your operating system you have connected the incorrect program which is unable to perform the GIFs with animations. Connect GIF with a browser or image viewer.

If it happens that the size of GIF files becomes too large, it may freeze during playing due to each frame should be converted into the full-bitmap while its playback. To avoid that situation you must lower your frame rate, resize and optimize the animation and you can try to make the animation in some other formats - either MP4 or WebP.

Some viewers clamp delay in milliseconds around the value 20-100 and you should adjust that delay in your editor. Sometimes you can see the "halo" effect of the transparent pixels as the GIF supports only one binary mask of the opacity.

Security considerations

There is also no native language, embed code, and scripting involved when it comes to using either format; as such, using an everyday .GIF file is safer in comparison to opening any type of document that supports macros usage. The most significant risk lies in the decoder: memory vulnerabilities were found in browsers, in OS image processing libraries and in editors, so it’s wise to be updated about Google Chrome, Firefox, Safari, Microsoft Photos, macOS’s Preview app, GIMP, ImageMagick, and IrfanView in regard to this.

Take a peek on the initial 6 byte sequence for 47 49 46 38 37 61 or 47 49 46 38 39 61. Hackers often just name a completely different file format into something.gif. A comment and extension block will store some sort of text or data of an application kind and won’t have nearly as much metadata as JPEG and TIFF EXIF do, however. GIFs are used by websites as remote trackers in small sizes and will transmit one’s IP, User agent string, current time, and referring site name.

History and versions

The Graphics Interchange Format (GIF) was developed and introduced in 1987 in the form of the GIF87a with the aim of offering an easy way of transmitting colorful visual content in networks with constrained dial-up connections. It included compression using the LZW method, which was patented back then by Unisys leading eventually to the licensing problems for creators of websites or any software. Version 89a that offered features such as transparency, comments field, text rendition capability, as well as control and application extensions and animated GIF ability came out in 1989, after which Netscape Application Extension for GIFs started making loopable animations popular in 1990s browsers. PNG, that partly appeared as an attempt to replace GIFs because of the latter's LZW compression patents issue (as a replacement for non-animated images) in mid 1990s, did not replace animated version. By 2004 all the LZW compression patents expired in main countries, making encoding/decoding issue irrelevant anymore. Current specifications of GIF89a can be viewed online from W3C while the MIME type image/gif remains registered and broadly interoperable although GIF is far from being ISO standard for images.

PNG is generally considered the best format for static pictures used on the World Wide Web because of its lossless nature, capability of displaying truecolor and alpha channels, text sharpness and precision of flat objects rendering. Ordinary PNG files do not include an animation component, that is why it cannot substitute GIF when it comes to animations creation. The introduction of the APNG extension to the PNG (.png and .apng extensions) means bringing together such two features like animation and perfect alpha channel as well as better color performance in the same single format but, unfortunately, older editors/viewers/publication services use GIF more frequently. WebP can also employ lossy/lossless compression techniques as well as animation capabilities, and alpha channel, and animated files of this kind generally have smaller file size than their corresponding GIFs but, however, some ancient programs may not be able to open them. The same with AVIF format which uses better compression techniques as well as better color support including the animation in some scenarios. JPEG is used mostly with photographic pictures, and, on the other hand, for animations it is recommended to use formats MP4/WebM as file sizes become notably smaller and, besides this reason, these formats produce much better quality playback.

Comments (0)

Replying to

No comments yet. Be the first to share your experience with this file type.