Create high quality GIFs on your Mac

Friday 23. October 2020 16:11:17 UTC+01:00 - Thomas Zoechling

GIF is probably one of the most resilient file formats still around. The original version of the specification was released in 1987, a slightly revised version came out two years later. That’s the version of GIF we are using ever since. While the world has changed a lot since the 80s, GIF hasn’t. Due to its widespread support, GIF is still a good candidate for certain tasks. For example content shared via e-mail. Newsletters or product support answers can't rely on video playback capabilities at the receivers side. Also some websites still don't accept video uploads but they often do support images and animated image formats like GIF.

optimized GIF showing a waterfall

A highly optimized animated GIF (777KB). The footage was extracted from a HD video file. Color count reduced to 70.

In comparison to modern video codecs, the old age of the format takes its toll when it comes to file size and visual quality. In this post, we’ll have a look how you can still achieve good looking results when creating GIFs while also keeping the file size small.

Reduce GIF File Size and Optimize Visual Quality

Trim Playback Length

In most cases you will not need the entire video sequence for the GIF animation, so you can trim the video in the playback window. Use the "Trim" item in the "Modify" menu to open a UI that allows you to define the start and end points of your animation. You can also use the Touch Bar or the cmd+T keyboard shortcut.

Reduce Video Size

You can either reduce the video size by using the "Crop" command in the "Modify" menu or later, in the export sheet. By using the "Crop" command, you are cutting away unwanted portions of the video, whilst the export sheet allows you to resize your content. Resized GIFs show the full portion of the video but at a lower resolution. Both features - Crop and Resize - reduce export time and file size. The "Crop" feature is also accessible via the cmd+k keyboard shortcut or via the Touch Bar.

Tweak the Number of Colours

The most relevant option for optimizing the size of a GIF file is the number of colors used in the color table. GIF uses an 8-bit color table and thus the maximum number of colors is 256. Using a smaller color table with less colours can drastically reduce the file size. But removing colors from the video also has an impact on visual quality. The Claquette export sheet allows you to experiment with the color settings of your GIF in real time. You can find the color settings in the "Advanced Options" section of the "Animation" export sheet. Use the "Export to..." - "Animation" item in the "File" menu to open the export sheet.

Experiment with Dithering

Dithering helps to compensate the effects of the low color depth in GIF images. It simulates colors that are not available in the palette by intentionally applying noise patterns. Claquette provides a "Dithering Level" slider in the "Advanced Options" section of the "Animation" export sheet. Using a high dithering level can improve the visual quality of the GIF but it can also increase file size. Applying dithering works best for footage that contains a lot of natural textures or gradients. The reduced color count in GIFs can introduce banding effects in such scenes and dithering can revert those effects to a certain degree. Computer graphics or screen recordings often feature flat, uniformly colored areas. Content with those qualities doesn't benefit from dithering.

Difference between dithering and no dithering

A magnified frame of the above animation with even less colors. Without dithering, the sky showcases noticable color banding.

Choose the right Frame Rate

The timing of GIF animations is measured in hundredths of a second. Exact values corresponding to traditional frame rates (like 30 FPS) are not possible. The frame rate control in Claquette maps common frame rate settings to the best matching GIF frame timing. Higher frame rates usually result in larger files - However, this may vary depending on the exported footage. A screen recording where only the mouse cursor is in motion most of the time can use a high frame rate without adding much weight to the file size. This is because Claquette only encodes the changing areas of a frame into the final GIF.

Advanced Tweaks

Instead of writing each frame, pixel for pixel, Claquette only writes the difference between 2 frames into a GIF file. Two parameters that control the calculation of the frame difference are: "Diff Threshold" and "Diff Smoothing". Those settings control the accuracy that Claquette uses when comparing the current frame with the next one. A "Diff Threshold" level of "0" means, that a pixel of the current frame has to have the exact same color as the same pixel in the predecessor frame to be omitted. Videos with constant lighting and not much vertical motion usually can use higher values for "Diff Threshold". This can greatly reduce file size because it removes redundant pixel information and noise from the GIF. "Diff Smoothing" can be used to compensate side effects of "Diff threshold". The impact of those 2 settings is highly variable and depends on the nature of the video material. Claquette uses conservative starting values for both. Tweaking and experimenting with them can pay off greatly.

Additional Tipps

The "Adaptive" preset in the export sheet is a good starting point for starting your tweaks. It analyzes your content and initializes all parameters to values that maintain a good balance between file size and visual quality. When you start to edit specific parameters, Claquette automatically switches to the "Custom" preset. This preset always stores the last used set of parameters. Those settings will be loaded the next time you open the settings sheet. After you found a good setup, you can also use the Preset system in Claquette to store your current settings. Click on the "Preset" popup button and choose "Create Preset..." to provide a name for the current set of parameters.

Animated GIF Alternatives

While GIF is a versatile format, that can be displayed on almost every operating system and device, it has quality and size disadvantages when compared to modern video codecs. If the target medium supports them, it's better to choose modern video codecs like H.264 or HEVC . They provide way smaller file sizes and better visual quality. If the content is displayed on the web, removing the audio track and auto-playing an endless loop can emulate popular GIF features.
Another alternative is the lesser-known animated PNG format. aPNG is not as well-supported as animated GIF, but it does provides 32-bit color support. Claquette also supports editing and exporting animated PNGs.

Claquette is available as free download from the Mac App Store .