ImageOptionsBase

Inheritance: java.lang.Object, com.aspose.imaging.DisposableObject

All Implemented Interfaces: com.aspose.imaging.xmp.IHasXmpData

public abstract class ImageOptionsBase extends DisposableObject implements IHasXmpData

The image base options.

Methods

MethodDescription
isKeepMetadata()Gets a value whether to keep original image metadata on export.
setKeepMetadata(boolean value)A value whether to keep original image metadata on export.
getXmpData()Gets the XMP metadata container.
setXmpData(XmpPacketWrapper value)Sets the XMP metadata container.
getSource()Gets the source to create image in.
setSource(Source value)Gets or sets the source to create image in.
getPalette()Gets the color palette.
setPalette(IColorPalette value)Sets the color palette.
getResolutionSettings()Gets the resolution settings.
setResolutionSettings(ResolutionSetting value)Sets the resolution settings.
getVectorRasterizationOptions()Gets the vector rasterization options.
setVectorRasterizationOptions(VectorRasterizationOptions value)Sets the vector rasterization options.
getBufferSizeHint()Gets the buffer size hint which is defined max allowed size for all internal buffers.
setBufferSizeHint(int value)Sets the buffer size hint which is defined max allowed size for all internal buffers.
getMultiPageOptions()The multipage options
setMultiPageOptions(MultiPageOptions value)The multipage options
getFullFrame()Gets a value indicating whether [full frame].
setFullFrame(boolean value)Sets a value indicating whether [full frame].
getProgressEventHandler()Gets the progress event handler.
setProgressEventHandler(ProgressEventHandler value)Sets the progress event handler.
deepClone()Clones this instance.

isKeepMetadata()

public final boolean isKeepMetadata()

Gets a value whether to keep original image metadata on export.

Returns: boolean - a value whether to keep original image metadata on export.

setKeepMetadata(boolean value)

public final void setKeepMetadata(boolean value)

A value whether to keep original image metadata on export.

Parameters:

ParameterTypeDescription
valuebooleana value whether to keep original image metadata on export.

getXmpData()

public XmpPacketWrapper getXmpData()

Gets the XMP metadata container.

Value: The XMP data container.

Returns: XmpPacketWrapper - the XMP metadata container.

setXmpData(XmpPacketWrapper value)

public void setXmpData(XmpPacketWrapper value)

Sets the XMP metadata container.

Value: The XMP data container.

Parameters:

ParameterTypeDescription
valueXmpPacketWrapperthe XMP metadata container.

getSource()

public Source getSource()

Gets the source to create image in.

Returns: Source - The source to create image in.

setSource(Source value)

public void setSource(Source value)

Gets or sets the source to create image in.

Parameters:

ParameterTypeDescription
valueSourceThe source to create image in.

getPalette()

public IColorPalette getPalette()

Gets the color palette.

Returns: IColorPalette - The color palette.

setPalette(IColorPalette value)

public void setPalette(IColorPalette value)

Sets the color palette.

Parameters:

ParameterTypeDescription
valueIColorPaletteThe color palette.

Example: The following example shows how to palletize a BMP image to reduce its output size.


// Create a BMP image 100 x 100 px.
com.aspose.imaging.fileformats.bmp.BmpImage bmpImage = new com.aspose.imaging.fileformats.bmp.BmpImage(100, 100);
try {
    // The linear gradient from the left-top to the right-bottom corner of the image.
    com.aspose.imaging.brushes.LinearGradientBrush brush =
            new com.aspose.imaging.brushes.LinearGradientBrush(
                    new com.aspose.imaging.Point(0, 0),
                    new com.aspose.imaging.Point(bmpImage.getWidth(), bmpImage.getHeight()),
                    com.aspose.imaging.Color.getRed(),
                    com.aspose.imaging.Color.getGreen());

    // Fill the entire image with the linear gradient brush.
    com.aspose.imaging.Graphics gr = new com.aspose.imaging.Graphics(bmpImage);
    gr.fillRectangle(brush, bmpImage.getBounds());

    // 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.
    com.aspose.imaging.IColorPalette palette = com.aspose.imaging.ColorPaletteHelper.getCloseImagePalette(bmpImage, 256);

    // 8-bit palette contains at most 256 colors.
    com.aspose.imaging.imageoptions.BmpOptions saveOptions = new com.aspose.imaging.imageoptions.BmpOptions();
    saveOptions.setPalette(palette);
    saveOptions.setBitsPerPixel(8);

    java.io.ByteArrayOutputStream stream = new java.io.ByteArrayOutputStream();
    try {
        bmpImage.save(stream, saveOptions);
        System.out.println("The palettized image size is " + stream.size() + " bytes.");
    } finally {
        stream.close();
    }

    stream = new java.io.ByteArrayOutputStream();
    try {
        bmpImage.save(stream);
        System.out.println("The non-palettized image size is " + stream.size() + " bytes.");
    } finally {
        stream.close();
    }
} finally {
    bmpImage.dispose();
}

// The output looks like this:
// The palettized image size is 11078 bytes.
// The non-palettized image size is 40054 bytes.

getResolutionSettings()

public ResolutionSetting getResolutionSettings()

Gets the resolution settings.

Returns: ResolutionSetting

setResolutionSettings(ResolutionSetting value)

public void setResolutionSettings(ResolutionSetting value)

Sets the resolution settings.

Parameters:

ParameterTypeDescription
valueResolutionSetting

Example: The following example loads a BMP image and saves it to JPEG using various save options.

String dir = "c:\\temp\\";

// Load a BMP image from a file.
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.bmp");
try {
    // Do some image processing.

    // Use additional options to specify the desired image parameters.
    com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions();

    // The number of bits per channel is 8.
    // When a palette is used, the color index is stored in the image data instead of the color itself.
    saveOptions.setBitsPerChannel((byte) 8);

    // Set the progressive type of compression.
    saveOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive);

    // Set the image quality. It is a value between 1 and 100.
    saveOptions.setQuality(100);

    // Set the horizontal/vertical resolution to 96 dots per inch.
    saveOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0));
    saveOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch);

    // If the source image is colored, it will be converted to grayscaled.
    saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Grayscale);

    // Use a palette to reduce the output size.
    saveOptions.setPalette(com.aspose.imaging.ColorPaletteHelper.create8BitGrayscale(false));

    image.save(dir + "sample.palettized.jpg", saveOptions);
} finally {
    image.dispose();
}

getVectorRasterizationOptions()

public VectorRasterizationOptions getVectorRasterizationOptions()

Gets the vector rasterization options.

Returns: VectorRasterizationOptions - The vector rasterization options.

setVectorRasterizationOptions(VectorRasterizationOptions value)

public void setVectorRasterizationOptions(VectorRasterizationOptions value)

Sets the vector rasterization options.

Parameters:

ParameterTypeDescription
valueVectorRasterizationOptionsThe vector rasterization options.

getBufferSizeHint()

public final int getBufferSizeHint()

Gets the buffer size hint which is defined max allowed size for all internal buffers.

Value: The buffer size hint, in megabytes. Non-positive value means no memory limitation for internal buffers

Returns: int - the buffer size hint which is defined max allowed size for all internal buffers.

setBufferSizeHint(int value)

public final void setBufferSizeHint(int value)

Sets the buffer size hint which is defined max allowed size for all internal buffers.

Value: The buffer size hint, in megabytes. Non-positive value means no memory limitation for internal buffers

Parameters:

ParameterTypeDescription
valueintthe buffer size hint which is defined max allowed size for all internal buffers.

getMultiPageOptions()

public MultiPageOptions getMultiPageOptions()

The multipage options

Returns: MultiPageOptions

setMultiPageOptions(MultiPageOptions value)

public void setMultiPageOptions(MultiPageOptions value)

The multipage options

Parameters:

ParameterTypeDescription
valueMultiPageOptions

getFullFrame()

public final boolean getFullFrame()

Gets a value indicating whether [full frame].

Value: true if [full frame]; otherwise, false.

Returns: boolean - a value indicating whether [full frame].

setFullFrame(boolean value)

public final void setFullFrame(boolean value)

Sets a value indicating whether [full frame].

Value: true if [full frame]; otherwise, false.

Parameters:

ParameterTypeDescription
valuebooleana value indicating whether [full frame].

getProgressEventHandler()

public ProgressEventHandler getProgressEventHandler()

Gets the progress event handler.

Value: The progress event handler.

Returns: ProgressEventHandler - the progress event handler.

setProgressEventHandler(ProgressEventHandler value)

public void setProgressEventHandler(ProgressEventHandler value)

Sets the progress event handler.

Value: The progress event handler.

Parameters:

ParameterTypeDescription
valueProgressEventHandlerthe progress event handler.

Example: The following example shows how to print information about progress events for load/export operations.

String dir = "c:\\aspose.imaging\\java\\issues\\1440\\";
String fileName = dir + "big.png";

// Example of use of separate operation progress event handlers for load/export operations
final com.aspose.imaging.ProgressEventHandler loadHandler = new com.aspose.imaging.ProgressEventHandler() {
    @Override
    public void invoke(com.aspose.imaging.progressmanagement.ProgressEventHandlerInfo info) {
        System.out.format("Load event %s : %d/%d\n", com.aspose.imaging.progressmanagement.EventType.toString(com.aspose.imaging.progressmanagement.EventType.class, info.getEventType()), info.getValue(), info.getMaxValue());
    }
};

final com.aspose.imaging.ProgressEventHandler exportHandler = new com.aspose.imaging.ProgressEventHandler() {
    @Override
    public void invoke(com.aspose.imaging.progressmanagement.ProgressEventHandlerInfo info) {
        System.out.format("Export event %s : %d/%d\n", com.aspose.imaging.progressmanagement.EventType.toString(com.aspose.imaging.progressmanagement.EventType.class, info.getEventType()), info.getValue(), info.getMaxValue());
    }
};

com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName, new com.aspose.imaging.LoadOptions() {{ setProgressEventHandler(loadHandler); }} );
try {
    image.save(fileName + ".psd",
            new com.aspose.imaging.imageoptions.PsdOptions() {{ setProgressEventHandler( exportHandler); }});
}
finally {
    image.close();
}

// The STDOUT log may look like this:
//        Load event Initialization : 1/4
//        Load event PreProcessing : 2/4
//        Load event Processing : 3/4
//        Load event Finalization : 4/4
//        Export event Initialization : 1/4
//        Export event PreProcessing : 2/4
//        Export event Processing : 3/4
//        Export event RelativeProgress : 1/1
//        Load event RelativeProgress : 1/1
//        Export event Finalization : 4/4

deepClone()

public ImageOptionsBase deepClone()

Clones this instance.

Returns: ImageOptionsBase - Returns shallow copy of this instance