diff --git a/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs b/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs
index 877931772..5fb3e4b8e 100644
--- a/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs
+++ b/src/ImageProcessorCore/Formats/Gif/GifEncoder.cs
@@ -131,7 +131,7 @@ namespace ImageProcessorCore.Formats
private QuantizedImage WriteColorTable(ImageBase image, Stream stream, int quality, int bitDepth)
{
// Quantize the image returning a palette.
- QuantizedImage quantizedImage = this.Quantizer.Quantize(image, quality.Clamp(1, 255));
+ QuantizedImage quantizedImage = this.Quantizer.Quantize(image, quality);
// Grab the palette and write it to the stream.
Bgra32[] palette = quantizedImage.Palette;
@@ -162,6 +162,7 @@ namespace ImageProcessorCore.Formats
///
/// The to encode.
/// The stream to write to.
+ /// The index of the color in the color palette to make transparent.
private void WriteGraphicalControlExtension(ImageBase image, Stream stream, int transparencyIndex)
{
// TODO: Check transparency logic.
@@ -189,7 +190,7 @@ namespace ImageProcessorCore.Formats
this.WriteByte(stream, packed);
this.WriteShort(stream, extension.DelayTime);
- this.WriteByte(stream, extension.TransparencyIndex);
+ this.WriteByte(stream, extension.TransparencyIndex == -1 ? 255 : extension.TransparencyIndex);
this.WriteByte(stream, GifConstants.Terminator);
}
diff --git a/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs b/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs
index 5ee54d762..3c66cc944 100644
--- a/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs
+++ b/src/ImageProcessorCore/Quantizers/Octree/Quantizer.cs
@@ -37,7 +37,7 @@ namespace ImageProcessorCore.Quantizers
///
/// Gets or sets the transparency index.
///
- public int TransparentIndex { get; protected set; }
+ public int TransparentIndex { get; protected set; } = -1;
///
public virtual QuantizedImage Quantize(ImageBase image, int maxColors)
diff --git a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
index 660e5e5af..9bb4e5f84 100644
--- a/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
+++ b/src/ImageProcessorCore/Quantizers/Wu/WuQuantizer.cs
@@ -715,7 +715,7 @@ namespace ImageProcessorCore.Quantizers
{
List pallette = new List();
byte[] pixels = new byte[image.Width * image.Height];
- int transparentIndex = 0;
+ int transparentIndex = -1;
for (int k = 0; k < colorCount; k++)
{