Packages

 

com.aspose.imaging

Interfaces

Classes

Exceptions

com.aspose.imaging

Class PaletteMiningMethod

  • java.lang.Object
    • com.aspose.ms.System.ValueType<com.aspose.ms.System.Enum>
      • com.aspose.ms.System.Enum
        • com.aspose.imaging.PaletteMiningMethod


  • public final class PaletteMiningMethod
    extends com.aspose.ms.System.Enum

    The image palette mining method

    Code example:

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


    
    // Loads png image        
    String sourceFilePath = "OriginalRings.png";
    String outputFilePath = "OriginalRingsOutput.png";
    try (com.aspose.imaging.Image image = com.aspose.imaging.Image.load(sourceFilePath))
    {
        com.aspose.imaging.imageoptions.PngOptions options = new com.aspose.imaging.imageoptions.PngOptions();
        options.setProgressive(true);
        // Use indexed color type
        options.setColorType(com.aspose.imaging.fileformats.png.PngColorType.IndexedColor);
        // Use maximal compression
        options.setCompressionLevel(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.
        options.setPalette(com.aspose.imaging.ColorPaletteHelper.getCloseImagePalette((com.aspose.imaging.RasterImage)image, 
                                    256, Aspose.Imaging.PaletteMiningMethod.Histogram));
                         
        image.save(outputFilePath, options);
    }
    // The output file size should be significantly reduced
    

    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.aspose.ms.System.Enum

        com.aspose.ms.System.Enum.AbstractEnum, com.aspose.ms.System.Enum.FlaggedEnum, com.aspose.ms.System.Enum.ObjectEnum, com.aspose.ms.System.Enum.SimpleEnum
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int ColorClustering
      The color clustering method
      static int Histogram
      The histogram method
      static int UseCurrentPalette
      Use exisiting palette of the image
      • Fields inherited from class com.aspose.ms.System.Enum

        EnumSeparatorCharArray
    • Method Summary

      • Methods inherited from class com.aspose.ms.System.Enum

        Clone, CloneTo, format, format, get_Caption, get_Value, getName, getName, getNames, getNames, getNames, getUnderlyingType, getUnderlyingType, getValue, getValues, getValues, getValues, isDefined, isDefined, isDefined, isDefined, parse, parse, parse, parse, register, toObject, toString
    • Field Detail

      • UseCurrentPalette

        public static final int UseCurrentPalette

        Use exisiting palette of the image

        See Also:
        Constant Field Values
      • ColorClustering

        public static final int ColorClustering

        The color clustering method

        See Also:
        Constant Field Values