diff --git a/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs b/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs
index 38c3484c81..d8af4c3260 100644
--- a/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs
+++ b/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs
@@ -61,6 +61,6 @@ namespace SixLabors.ImageSharp.Formats.Png
///
/// Gets the optimize method.
///
- PngOptimizeMethod? OptimizeMethod { get; }
+ PngChunkFilter? OptimizeMethod { get; }
}
}
diff --git a/src/ImageSharp/Formats/Png/PngOptimizeMethod.cs b/src/ImageSharp/Formats/Png/PngChunkFilter.cs
similarity index 52%
rename from src/ImageSharp/Formats/Png/PngOptimizeMethod.cs
rename to src/ImageSharp/Formats/Png/PngChunkFilter.cs
index 7ad6646380..49af6ce594 100644
--- a/src/ImageSharp/Formats/Png/PngOptimizeMethod.cs
+++ b/src/ImageSharp/Formats/Png/PngChunkFilter.cs
@@ -9,41 +9,41 @@ namespace SixLabors.ImageSharp.Formats.Png
/// Provides enumeration of available PNG optimization methods.
///
[Flags]
- public enum PngOptimizeMethod
+ public enum PngChunkFilter
{
///
- /// With the None filter, the scanline is transmitted unmodified.
+ /// With the None filter, all chunks will be written.
///
None = 0,
///
- /// Suppress the physical dimension information chunk.
+ /// Excludes the physical dimension information chunk from encoding.
///
- SuppressPhysicalChunk = 1,
+ ExcludePhysicalChunk = 1 << 0,
///
- /// Suppress the gamma information chunk.
+ /// Excludes the gamma information chunk from encoding.
///
- SuppressGammaChunk = 2,
+ ExcludeGammaChunk = 1 << 1,
///
- /// Suppress the eXIf chunk.
+ /// Excludes the eXIf chunk from encoding.
///
- SuppressExifChunk = 4,
+ ExcludeExifChunk = 1 << 2,
///
- /// Suppress the tTXt, iTXt or zTXt chunk.
+ /// Excludes the tTXt, iTXt or zTXt chunk from encoding.
///
- SuppressTextChunks = 8,
+ ExcludeTextChunks = 1 << 3,
///
- /// Make funlly transparent pixels black.
+ /// Make fully transparent pixels black.
///
MakeTransparentBlack = 16,
///
/// All possible optimizations.
///
- All = 31,
+ ExcludeAll = ExcludePhysicalChunk | ExcludeGammaChunk | ExcludeExifChunk | ExcludeTextChunks
}
}
diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs
index 0f83d3d42e..c417ea872c 100644
--- a/src/ImageSharp/Formats/Png/PngEncoder.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoder.cs
@@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Formats.Png
///
/// Gets or sets the optimize method.
///
- public PngOptimizeMethod? OptimizeMethod { get; set; }
+ public PngChunkFilter? OptimizeMethod { get; set; }
///
/// Encodes the image to the specified stream from the .
diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
index 47a377e67a..89c0b7f654 100644
--- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
@@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Formats.Png
PngMetadata pngMetadata = metadata.GetFormatMetadata(PngFormat.Instance);
PngEncoderOptionsHelpers.AdjustOptions(this.options, pngMetadata, out this.use16Bit, out this.bytesPerPixel);
IndexedImageFrame quantized;
- if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.MakeTransparentBlack) == PngOptimizeMethod.MakeTransparentBlack)
+ if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.MakeTransparentBlack) == PngChunkFilter.MakeTransparentBlack)
{
using (Image tempImage = image.Clone())
{
@@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.WriteHeaderChunk(stream);
- if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressGammaChunk) != PngOptimizeMethod.SuppressGammaChunk)
+ if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeGammaChunk) != PngChunkFilter.ExcludeGammaChunk)
{
this.WriteGammaChunk(stream);
}
@@ -190,17 +190,17 @@ namespace SixLabors.ImageSharp.Formats.Png
this.WritePaletteChunk(stream, quantized);
this.WriteTransparencyChunk(stream, pngMetadata);
- if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressPhysicalChunk) != PngOptimizeMethod.SuppressPhysicalChunk)
+ if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludePhysicalChunk) != PngChunkFilter.ExcludePhysicalChunk)
{
this.WritePhysicalChunk(stream, metadata);
}
- if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressExifChunk) != PngOptimizeMethod.SuppressExifChunk)
+ if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeExifChunk) != PngChunkFilter.ExcludeExifChunk)
{
this.WriteExifChunk(stream, metadata);
}
- if (((this.options.OptimizeMethod ?? PngOptimizeMethod.None) & PngOptimizeMethod.SuppressTextChunks) != PngOptimizeMethod.SuppressTextChunks)
+ if (((this.options.OptimizeMethod ?? PngChunkFilter.None) & PngChunkFilter.ExcludeTextChunks) != PngChunkFilter.ExcludeTextChunks)
{
this.WriteTextChunks(stream, pngMetadata);
}
diff --git a/src/ImageSharp/Formats/Png/PngEncoderOptions.cs b/src/ImageSharp/Formats/Png/PngEncoderOptions.cs
index 89d7b0d5ef..4728b7ca83 100644
--- a/src/ImageSharp/Formats/Png/PngEncoderOptions.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoderOptions.cs
@@ -83,6 +83,6 @@ namespace SixLabors.ImageSharp.Formats.Png
///
/// Gets or sets a the optimize method.
///
- public PngOptimizeMethod? OptimizeMethod { get; set; }
+ public PngChunkFilter? OptimizeMethod { get; set; }
}
}
diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
index ce734f6cfb..e2051ea277 100644
--- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
@@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
appendPngColorType: true,
appendPixelType: true,
appendPngBitDepth: true,
- optimizeMethod: PngOptimizeMethod.All);
+ optimizeMethod: PngChunkFilter.ExcludeAll);
}
}
@@ -589,7 +589,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
bool appendCompressionLevel = false,
bool appendPaletteSize = false,
bool appendPngBitDepth = false,
- PngOptimizeMethod optimizeMethod = PngOptimizeMethod.None)
+ PngChunkFilter optimizeMethod = PngChunkFilter.None)
where TPixel : unmanaged, IPixel
{
using (Image image = provider.GetImage())