PngColorType

PngColorType enumeration

Represents the PNG image color type.

public enum PngColorType

Values

NameValueDescription
Grayscale0Represents the color type where each pixel is a greyscale sample.
Truecolor2Represents the color type where each pixel is an R,G,B triple.
IndexedColor3Represents the color type where each pixel is a palette index; a PLTE chunk shall appear.
GrayscaleWithAlpha4Represents the color type where each pixel is a greyscale sample followed by an alpha sample.
TruecolorWithAlpha6Represents the color type where each pixel is an R,G,B triple followed by an alpha sample.

Examples

The following example shows how to compress a PNG image, using indexed color with best fit palette

[C#]

// Loads png image        
    string  sourceFilePath="OriginalRings.png";
    string  outputFilePath="OriginalRingsOutput.png";
    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(sourceFilePath))
{
    image.Save(outputFilePath, new Aspose.Imaging.ImageOptions.PngOptions()
    {
         Progressive = true,
             // Use indexed color type
         ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.IndexedColor,
             // Use maximal compression
         CompressionLevel = 9,
      // Get the closest 8-bit color palette which covers as many pixels as possible, so that a palettized image
         // is almost visually indistinguishable from a non-palletized one.
         Palette = Aspose.Imaging.ColorPaletteHelper.GetCloseImagePalette((Aspose.Imaging.RasterImage)image, 256, Aspose.Imaging.PaletteMiningMethod.Histogram)
    });
}
    // The output file size should be significantly reduced

See Also