Jpeg2000Options

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

public class Jpeg2000Options extends ImageOptionsBase

Create JPEG2000 (JP2) image files with our API, utilizing advanced wavelet technology for coding lossless content. Benefit from support for various codecs, including irreversible and lossless compression, as well as XMP metadata containers, ensuring versatility and high-quality image creation tailored to your needs.

Constructors

ConstructorDescription
Jpeg2000Options()Initializes a new instance of the Jpeg2000Options class.
Jpeg2000Options(Jpeg2000Options jpeg2000Options)Initializes a new instance of the Jpeg2000Options class.

Methods

MethodDescription
getXmpData()Gets or sets the XMP metadata container.
setXmpData(XmpPacketWrapper value)Gets or sets the XMP metadata container.
getComments()Gets or sets the Jpeg comment markers.
setComments(String[] value)Gets or sets the Jpeg comment markers.
getCodec()Gets or sets the JPEG2000 codec
setCodec(int value)Gets or sets the JPEG2000 codec
getCompressionRatios()Gets or sets the Array of compression ratio.
setCompressionRatios(int[] value)Gets or sets the Array of compression ratio.
getIrreversible()Gets a value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression (default).
setIrreversible(boolean value)Sets a value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression (default).

Example: The following example shows how to convert a multipage vector image to JPEG 2000 format in general way without referencing to a particular image type.

String dir = "C:\\aspose.imaging\\net\\misc\\ImagingReleaseQATester\\Tests\\testdata\\2548";
String inputFilePath = (dir + "Multipage.cdr");
String outputFilePath = (dir + "Multipage.cdr.j2k");

com.aspose.imaging.ImageOptionsBase exportOptions = new com.aspose.imaging.imageoptions.Jpeg2000Options();

try (com.aspose.imaging.Image image = com.aspose.imaging.Image.load(inputFilePath))
{
    exportOptions.setMultiPageOptions(null);

    // Export only first two pages. In fact, only one page will be rasterized because JPEG 2000 is not a multi-page format.
    com.aspose.imaging.IMultipageImage multipageImage = (image instanceof com.aspose.imaging.IMultipageImage) ? (com.aspose.imaging.IMultipageImage) image : null;
    if (multipageImage != null && (multipageImage.getPages() != null && multipageImage.getPageCount() > 2))
    {
        exportOptions.setMultiPageOptions(new com.aspose.imaging.imageoptions.MultiPageOptions(new com.aspose.imaging.IntRange(0, 2)));
    }

    if (image instanceof com.aspose.imaging.VectorImage)
    {
        com.aspose.imaging.imageoptions.VectorRasterizationOptions defaultOptions = (com.aspose.imaging.imageoptions.VectorRasterizationOptions) image.getDefaultOptions(new Object[]{Color.getWhite(), image.getWidth(), image.getHeight()});
        exportOptions.setVectorRasterizationOptions(defaultOptions);
        defaultOptions.setTextRenderingHint(com.aspose.imaging.TextRenderingHint.SingleBitPerPixel);
        defaultOptions.setSmoothingMode(com.aspose.imaging.SmoothingMode.None);
    }

    image.save(outputFilePath, exportOptions);
}

Jpeg2000Options()

public Jpeg2000Options()

Initializes a new instance of the Jpeg2000Options class.

Jpeg2000Options(Jpeg2000Options jpeg2000Options)

public Jpeg2000Options(Jpeg2000Options jpeg2000Options)

Initializes a new instance of the Jpeg2000Options class.

Parameters:

ParameterTypeDescription
jpeg2000OptionsJpeg2000OptionsThe Jpeg2000 file format options to copy settings from.

getXmpData()

public XmpPacketWrapper getXmpData()

Gets or sets the XMP metadata container.

Returns: XmpPacketWrapper - The XMP data container.

setXmpData(XmpPacketWrapper value)

public void setXmpData(XmpPacketWrapper value)

Gets or sets the XMP metadata container.

Parameters:

ParameterTypeDescription
valueXmpPacketWrapperThe XMP data container.

getComments()

public String[] getComments()

Gets or sets the Jpeg comment markers.

Returns: java.lang.String[] - The Jpeg comment markers.

setComments(String[] value)

public void setComments(String[] value)

Gets or sets the Jpeg comment markers.

Parameters:

ParameterTypeDescription
valuejava.lang.String[]The Jpeg comment markers.

getCodec()

public int getCodec()

Gets or sets the JPEG2000 codec

Returns: int - The JPEG2000 codec

setCodec(int value)

public void setCodec(int value)

Gets or sets the JPEG2000 codec

Parameters:

ParameterTypeDescription
valueintThe JPEG2000 codec

Example: This example shows how to create a PNG image and save it to JPEG2000 with the desired options.

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

// Create a PNG image of 100x100 px.
com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100);
try {
    com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);

    // Fill the entire image in red.
    com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
    graphics.fillRectangle(brush, pngImage.getBounds());

    com.aspose.imaging.imageoptions.Jpeg2000Options saveOptions = new com.aspose.imaging.imageoptions.Jpeg2000Options();

    // Use the irreversible Discrete Wavelet Transform 9-7
    saveOptions.setIrreversible(true);

    // JP2 is the "container" format for JPEG 2000 codestreams.
    // J2K is raw compressed data, without a wrapper.
    saveOptions.setCodec(com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Codec.J2K);

    // Save to a file
    pngImage.save(dir + "output.j2k", saveOptions);
} finally {
    pngImage.dispose();
}

getCompressionRatios()

public int[] getCompressionRatios()

Gets or sets the Array of compression ratio. Different compression ratios for successive layers. The rate specified for each quality level is the desired compression factor. Decreasing ratios required.

Returns: int[] - The compression ratios.

setCompressionRatios(int[] value)

public void setCompressionRatios(int[] value)

Gets or sets the Array of compression ratio. Different compression ratios for successive layers. The rate specified for each quality level is the desired compression factor. Decreasing ratios required.

Parameters:

ParameterTypeDescription
valueint[]The compression ratios.

getIrreversible()

public boolean getIrreversible()

Gets a value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression (default).

Returns: boolean - a value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression

setIrreversible(boolean value)

public void setIrreversible(boolean value)

Sets a value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression (default).

Parameters:

ParameterTypeDescription
valuebooleana value indicating whether use the irreversible DWT 9-7 (true) or use lossless DWT 5-3 compression

Example: This example shows how to create a PNG image and save it to JPEG2000 with the desired options.

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

// Create a PNG image of 100x100 px.
com.aspose.imaging.fileformats.png.PngImage pngImage = new com.aspose.imaging.fileformats.png.PngImage(100, 100);
try {
    com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(pngImage);

    // Fill the entire image in red.
    com.aspose.imaging.brushes.SolidBrush brush = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
    graphics.fillRectangle(brush, pngImage.getBounds());

    com.aspose.imaging.imageoptions.Jpeg2000Options saveOptions = new com.aspose.imaging.imageoptions.Jpeg2000Options();

    // Use the irreversible Discrete Wavelet Transform 9-7
    saveOptions.setIrreversible(true);

    // JP2 is the "container" format for JPEG 2000 codestreams.
    // J2K is raw compressed data, without a wrapper.
    saveOptions.setCodec(com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Codec.J2K);

    // Save to a file
    pngImage.save(dir + "output.j2k", saveOptions);
} finally {
    pngImage.dispose();
}