PrettyGifs plugin

Replaces .NET's disgusting default GIF encoding algorithm with Octree quantization and dithering, and allows 8-bit PNG creation. Compatible with all plugins.


Either runInstall-Package ImageResizer.Plugins.PrettyGifsin the NuGet package manager, or:

  1. Add ImageResizer.Plugins.PrettyGifs to your project
  2. Add<add name="PrettyGifs" />inside<resizer><plugins></plugins></resizer>in Web.config.

Supported querystring commands

  • colors=2-256
  • dither=true|4pass
  • preservePalette=true|false - If true, will attempt to use the original palette if present instead of recalculating it.

Why not nQuant

A) On an informal test, it was 10x slower than the Octree algorithm on a 256x256 PNG. I.e, 1900ms vs 195ms. It also took 80MB of ram, while Octree took kilobytes.

B) It intrinsically requires 50MB ((32^4)x(6x8)=50,331,648 bytes) of ram per encode *just to store the histogram information for any size file*. This is an intrinsic limitation of Versus kilobytes for the Octree algorithm.

C) Only works for PNG files, it's designed for a multi-bit alpha channel. I could fix that, though.

D) The nQuant implementation also makes excessive copies of the image, making it scale poorly. For example, on a 1300x840 PNG, nuQuant took 18.8 seconds and 110-130MB of ram, while Octree took 0.3 seconds and 4-8MB of RAM. This is also fixable, I believe.

[1]: Default GIF: .NET Default GIF behaviour simulated with the 216 color web pallette in Adobe Photoshop. Results may differ depending upon your operating system. Pre-2009 versions of windows use a fixed pallette, while WS2008R2 and later use a different (although still poor) quantization system.

[2]: PrettyGif settings:   format = gif, colors = 216, dither = 4pass, preservePalette = false

This plugin (PrettyGifs plugin) is part of the Performance Edition

Where is the plugins section?

The <plugins> section is located in Web.config, and is nested inside the <resizer> element, which is nested inside <configuration>. For examples, see this sample Web.config file.

Where can I find the dll?

We prefer that you install via NuGet, but you can also find the plugin DLL files in the /dlls/release folder of your download.

How do I typically install a plugin via Web.Config?

  1. In Visual Studio, right click on your project and choose "Add reference". Browse to the plugin DLL and click "OK".
  2. In the <plugins> section of Web.config, insert <add name="PluginName" />
  3. Look at the plugin documentation to see what configuration options (if any) are available.

How do I typically install a plugin via code?