public class JpegOptions extends ImageOptionsBase
The jpeg file format create options.
This example demonstrates the use of different classes from SaveOptions Namespace for export purposes. An image of type Gif is loaded into an instance of Image and then exported out to several formats.
String dir = "c:\\temp\\"; //Load an existing image (of type Gif) in an instance of Image class com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.gif"); try { //Export to BMP file format using the default options image.save(dir + "output.bmp", new com.aspose.imaging.imageoptions.BmpOptions()); //Export to JPEG file format using the default options image.save(dir + "output.jpeg", new com.aspose.imaging.imageoptions.JpegOptions()); //Export to PNG file format using the default options image.save(dir + "output.png", new com.aspose.imaging.imageoptions.PngOptions()); //Export to TIFF file format using the default options image.save(dir + "output.tif", new com.aspose.imaging.imageoptions.TiffOptions(com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat.Default)); } finally { image.dispose(); }
Constructor and Description |
---|
JpegOptions()
Initializes a new instance of the
JpegOptions class. |
JpegOptions(JpegOptions jpegOptions)
Initializes a new instance of the
JpegOptions class. |
Modifier and Type | Method and Description |
---|---|
byte |
getBitsPerChannel()
Gets bits per channel for lossless jpeg image.
|
StreamSource |
getCmykColorProfile()
The destination CMYK color profile for CMYK jpeg images.
|
int |
getColorType()
Gets the color type for jpeg image.
|
String |
getComment()
Gets the jpeg file comment.
|
int |
getCompressionType()
Gets the compression type.
|
int |
getDefaultMemoryAllocationLimit()
Deprecated.
Use com.aspose.imaging.Image.getBufferSizeHint(), com.aspose.imaging.ImageOptionsBase.getBufferSizeHint() or com.aspose.imaging.LoadOptions.getBufferSizeHint() instead.
|
JpegExifData |
getExifData()
Get or set exif data container
|
byte[] |
getHorizontalSampling()
Gets the horizontal subsamplings for each component.
|
JFIFData |
getJfif()
Gets the jfif.
|
int |
getJpegLsAllowedLossyError()
Gets the JPEG-LS difference bound for near-lossless coding (NEAR parameter from the JPEG-LS specification).
|
int |
getJpegLsInterleaveMode()
Gets the JPEG-LS interleave mode.
|
JpegLsPresetCodingParameters |
getJpegLsPreset()
Gets the JPEG-LS preset parameters.
|
boolean |
getPreblendAlphaIfPresent()
Gets a value indicating whether red, green and blue components should be mixed with a background color, if alpha channel is present.
|
int |
getQuality()
Gets image quality.
|
RdOptimizerSettings |
getRdOptSettings()
Gets the RD optimizer settings.
|
byte |
getResolutionUnit()
Gets the resolution unit.
|
StreamSource |
getRgbColorProfile()
The destination RGB color profile for CMYK jpeg images.
|
int |
getSampleRoundingMode()
Gets the sample rounding mode to fit an 8-bit value to an n-bit value.
|
int |
getScaledQuality()
The scaled quality.
|
byte[] |
getVerticalSampling()
Gets the vertical subsamplings for each component.
|
XmpPacketWrapper |
getXmpData()
Gets the XMP metadata container.
|
void |
setBitsPerChannel(byte value)
Sets bits per channel for lossless jpeg image.
|
void |
setCmykColorProfile(StreamSource value)
The destination CMYK color profile for CMYK jpeg images.
|
void |
setColorType(int value)
Sets the color type for jpeg image.
|
void |
setComment(String value)
Sets the jpeg file comment.
|
void |
setCompressionType(int value)
Sets the compression type.
|
void |
setDefaultMemoryAllocationLimit(int value)
Deprecated.
Use com.aspose.imaging.Image.setBufferSizeHint(int), com.aspose.imaging.ImageOptionsBase.setBufferSizeHint(int) or com.aspose.imaging.LoadOptions.setBufferSizeHint(int) instead.
|
void |
setExifData(JpegExifData value)
Get or set exif data container
|
void |
setHorizontalSampling(byte[] value)
Sets the horizontal subsamplings for each component.
|
void |
setJfif(JFIFData value)
Sets the jfif.
|
void |
setJpegLsAllowedLossyError(int value)
Sets the JPEG-LS difference bound for near-lossless coding (NEAR parameter from the JPEG-LS specification).
|
void |
setJpegLsInterleaveMode(int value)
Sets the JPEG-LS interleave mode.
|
void |
setJpegLsPreset(JpegLsPresetCodingParameters value)
Sets the JPEG-LS preset parameters.
|
void |
setPreblendAlphaIfPresent(boolean value)
Sets a value indicating whether red, green and blue components should be mixed with a background color, if alpha channel is present.
|
void |
setQuality(int value)
Sets image quality.
|
void |
setRdOptSettings(RdOptimizerSettings value)
Sets the RD optimizer settings.
|
void |
setResolutionUnit(byte value)
Sets the resolution unit.
|
void |
setRgbColorProfile(StreamSource value)
The destination RGB color profile for CMYK jpeg images.
|
void |
setSampleRoundingMode(int value)
Sets the sample rounding mode to fit an 8-bit value to an n-bit value.
|
void |
setVerticalSampling(byte[] value)
Sets the vertical subsamplings for each component.
|
void |
setXmpData(XmpPacketWrapper value)
Sets the XMP metadata container.
|
deepClone, getBufferSizeHint, getMultiPageOptions, getPalette, getProgressEventHandler, getResolutionSettings, getSource, getVectorRasterizationOptions, setBufferSizeHint, setMultiPageOptions, setPalette, setProgressEventHandler, setResolutionSettings, setSource, setVectorRasterizationOptions
close, dispose, getDisposed
public JpegOptions()
Initializes a new instance of the JpegOptions
class.
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(); }
public JpegOptions(JpegOptions jpegOptions)
Initializes a new instance of the JpegOptions
class.
jpegOptions
- The JPEG options.@Deprecated public int getDefaultMemoryAllocationLimit()
Gets the default memory allocation limit.
@Deprecated public void setDefaultMemoryAllocationLimit(int value)
Sets the default memory allocation limit.
value
- The default memory allocation limit.public XmpPacketWrapper getXmpData()
Gets the XMP metadata container.
getXmpData
in class ImageOptionsBase
public void setXmpData(XmpPacketWrapper value)
Sets the XMP metadata container.
setXmpData
in class ImageOptionsBase
value
- The XMP data container.public JFIFData getJfif()
Gets the jfif.
public void setJfif(JFIFData value)
Sets the jfif.
public String getComment()
Gets the jpeg file comment.
public void setComment(String value)
Sets the jpeg file comment.
public JpegExifData getExifData()
Get or set exif data container
public void setExifData(JpegExifData value)
Get or set exif data container
public int getCompressionType()
Gets the compression type.
public void setCompressionType(int value)
Sets the compression type.
The following example shows how to create JPEG image of the specified size with the specified parameters.
String dir = "c:\\temp\\"; // Create a JPEG image of 100x100 px. // Use additional options to specify the desired image parameters. com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions(); // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly. createOptions.setBitsPerChannel((byte) 8); // Set the progressive type of compression. createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive); // Set the image quality. It is a value between 1 and 100. createOptions.setQuality(100); // Set the horizontal/vertical resolution to 96 dots per inch. createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0)); createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch); // This is a standard option for JPEG images. // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed. createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr); com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage); com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getBlue()); // Fill the image with a grayscale gradient graphics.fillRectangle(gradientBrush, jpegImage.getBounds()); // Save to a file. jpegImage.save(dir + "output.explicitoptions.jpg"); } finally { jpegImage.dispose(); }
public int getColorType()
Gets the color type for jpeg image.
The following example shows how to create JPEG image of the specified size with the specified parameters.
String dir = "c:\\temp\\"; // Create a JPEG image of 100x100 px. // Use additional options to specify the desired image parameters. com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions(); // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly. createOptions.setBitsPerChannel((byte) 8); // Set the progressive type of compression. createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive); // Set the image quality. It is a value between 1 and 100. createOptions.setQuality(100); // Set the horizontal/vertical resolution to 96 dots per inch. createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0)); createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch); // This is a standard option for JPEG images. // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed. createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr); com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage); com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getBlue()); // Fill the image with a grayscale gradient graphics.fillRectangle(gradientBrush, jpegImage.getBounds()); // Save to a file. jpegImage.save(dir + "output.explicitoptions.jpg"); } finally { jpegImage.dispose(); }
public void setColorType(int value)
Sets the color type for jpeg image.
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(); }
public byte getBitsPerChannel()
Gets bits per channel for lossless jpeg image. Now we support from 2 to 8 bits per channel.
public void setBitsPerChannel(byte value)
Sets bits per channel for lossless jpeg image. Now we support from 2 to 8 bits per channel.
The following example shows how to create JPEG image of the specified size with the specified parameters.
String dir = "c:\\temp\\"; // Create a JPEG image of 100x100 px. // Use additional options to specify the desired image parameters. com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions(); // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly. createOptions.setBitsPerChannel((byte) 8); // Set the progressive type of compression. createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive); // Set the image quality. It is a value between 1 and 100. createOptions.setQuality(100); // Set the horizontal/vertical resolution to 96 dots per inch. createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0)); createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch); // This is a standard option for JPEG images. // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed. createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr); com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage); com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getBlue()); // Fill the image with a grayscale gradient graphics.fillRectangle(gradientBrush, jpegImage.getBounds()); // Save to a file. jpegImage.save(dir + "output.explicitoptions.jpg"); } finally { jpegImage.dispose(); }
public int getQuality()
Gets image quality.
public void setQuality(int value)
Sets image quality.
The following example shows how to create JPEG image of the specified size with the specified parameters.
String dir = "c:\\temp\\"; // Create a JPEG image of 100x100 px. // Use additional options to specify the desired image parameters. com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions(); // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly. createOptions.setBitsPerChannel((byte) 8); // Set the progressive type of compression. createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive); // Set the image quality. It is a value between 1 and 100. createOptions.setQuality(100); // Set the horizontal/vertical resolution to 96 dots per inch. createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0)); createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch); // This is a standard option for JPEG images. // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed. createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr); com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage); com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getBlue()); // Fill the image with a grayscale gradient graphics.fillRectangle(gradientBrush, jpegImage.getBounds()); // Save to a file. jpegImage.save(dir + "output.explicitoptions.jpg"); } finally { jpegImage.dispose(); }
public int getScaledQuality()
The scaled quality.
public RdOptimizerSettings getRdOptSettings()
Gets the RD optimizer settings.
public void setRdOptSettings(RdOptimizerSettings value)
Sets the RD optimizer settings.
value
- The RD optimizer settings.public StreamSource getRgbColorProfile()
The destination RGB color profile for CMYK jpeg images. Use for saving images. Must be in pair with CMYKColorProfile for correct color conversion.
public void setRgbColorProfile(StreamSource value)
The destination RGB color profile for CMYK jpeg images. Use for saving images. Must be in pair with CMYKColorProfile for correct color conversion.
The following example loads PNG and saves it to CMYK JPEG using custom ICC profile. Then loads CMYK JPEG and saves it back to PNG. The color conversion from RGB to CMYK and from CMYK to RGB is performed using custom ICC profiles.
String dir = "c:\\temp\\"; // Load PNG and save it to CMYK JPEG com.aspose.imaging.fileformats.png.PngImage image = (com.aspose.imaging.fileformats.png.PngImage) com.aspose.imaging.Image.load(dir + "sample.png"); try { java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc"); java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc"); try { com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions(); saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Cmyk); // Use custom ICC profiles saveOptions.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream)); saveOptions.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream)); image.save(dir + "output.cmyk.jpg", saveOptions); } finally { rgbProfileStream.close(); cmykProfileStream.close(); } } finally { image.dispose(); } // Load CMYK JPEG and save it to PNG com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "output.cmyk.jpg"); try { java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc"); java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc"); try { // Use custom ICC profiles jpegImage.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream)); jpegImage.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream)); com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions(); jpegImage.save(dir + "output.rgb.png", saveOptions); } finally { rgbProfileStream.close(); cmykProfileStream.close(); } } finally { jpegImage.dispose(); }
public StreamSource getCmykColorProfile()
The destination CMYK color profile for CMYK jpeg images. Use for saving images. Must be in pair with RGBColorProfile for correct color conversion.
public void setCmykColorProfile(StreamSource value)
The destination CMYK color profile for CMYK jpeg images. Use for saving images. Must be in pair with RGBColorProfile for correct color conversion.
The following example loads PNG and saves it to CMYK JPEG using custom ICC profile. Then loads CMYK JPEG and saves it back to PNG. The color conversion from RGB to CMYK and from CMYK to RGB is performed using custom ICC profiles.
String dir = "c:\\temp\\"; // Load PNG and save it to CMYK JPEG com.aspose.imaging.fileformats.png.PngImage image = (com.aspose.imaging.fileformats.png.PngImage) com.aspose.imaging.Image.load(dir + "sample.png"); try { java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc"); java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc"); try { com.aspose.imaging.imageoptions.JpegOptions saveOptions = new com.aspose.imaging.imageoptions.JpegOptions(); saveOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.Cmyk); // Use custom ICC profiles saveOptions.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream)); saveOptions.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream)); image.save(dir + "output.cmyk.jpg", saveOptions); } finally { rgbProfileStream.close(); cmykProfileStream.close(); } } finally { image.dispose(); } // Load CMYK JPEG and save it to PNG com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = (com.aspose.imaging.fileformats.jpeg.JpegImage) com.aspose.imaging.Image.load(dir + "output.cmyk.jpg"); try { java.io.InputStream rgbProfileStream = new java.io.FileInputStream(dir + "eciRGB_v2.icc"); java.io.InputStream cmykProfileStream = new java.io.FileInputStream(dir + "ISOcoated_v2_FullGamut4.icc"); try { // Use custom ICC profiles jpegImage.setRgbColorProfile(new com.aspose.imaging.sources.StreamSource(rgbProfileStream)); jpegImage.setCmykColorProfile(new com.aspose.imaging.sources.StreamSource(cmykProfileStream)); com.aspose.imaging.imageoptions.PngOptions saveOptions = new com.aspose.imaging.imageoptions.PngOptions(); jpegImage.save(dir + "output.rgb.png", saveOptions); } finally { rgbProfileStream.close(); cmykProfileStream.close(); } } finally { jpegImage.dispose(); }
public int getJpegLsAllowedLossyError()
Gets the JPEG-LS difference bound for near-lossless coding (NEAR parameter from the JPEG-LS specification).
public void setJpegLsAllowedLossyError(int value)
Sets the JPEG-LS difference bound for near-lossless coding (NEAR parameter from the JPEG-LS specification).
public int getJpegLsInterleaveMode()
Gets the JPEG-LS interleave mode.
public void setJpegLsInterleaveMode(int value)
Sets the JPEG-LS interleave mode.
public JpegLsPresetCodingParameters getJpegLsPreset()
Gets the JPEG-LS preset parameters.
public void setJpegLsPreset(JpegLsPresetCodingParameters value)
Sets the JPEG-LS preset parameters.
public byte[] getHorizontalSampling()
Gets the horizontal subsamplings for each component.
public void setHorizontalSampling(byte[] value)
Sets the horizontal subsamplings for each component.
public byte[] getVerticalSampling()
Gets the vertical subsamplings for each component.
public void setVerticalSampling(byte[] value)
Sets the vertical subsamplings for each component.
public int getSampleRoundingMode()
Gets the sample rounding mode to fit an 8-bit value to an n-bit value. P:JpegOptions.BitsPerChannel
public void setSampleRoundingMode(int value)
Sets the sample rounding mode to fit an 8-bit value to an n-bit value. P:JpegOptions.BitsPerChannel
public boolean getPreblendAlphaIfPresent()
Gets a value indicating whether red, green and blue components should be mixed with a background color, if alpha channel is present.
public void setPreblendAlphaIfPresent(boolean value)
Sets a value indicating whether red, green and blue components should be mixed with a background color, if alpha channel is present.
public final byte getResolutionUnit()
Gets the resolution unit.
The following example shows how to create JPEG image of the specified size with the specified parameters.
String dir = "c:\\temp\\"; // Create a JPEG image of 100x100 px. // Use additional options to specify the desired image parameters. com.aspose.imaging.imageoptions.JpegOptions createOptions = new com.aspose.imaging.imageoptions.JpegOptions(); // The number of bits per channel is 8, 8, 8 for Y, Cr, Cb components accordingly. createOptions.setBitsPerChannel((byte) 8); // Set the progressive type of compression. createOptions.setCompressionType(com.aspose.imaging.fileformats.jpeg.JpegCompressionMode.Progressive); // Set the image quality. It is a value between 1 and 100. createOptions.setQuality(100); // Set the horizontal/vertical resolution to 96 dots per inch. createOptions.setResolutionSettings(new com.aspose.imaging.ResolutionSetting(96.0, 96.0)); createOptions.setResolutionUnit(com.aspose.imaging.ResolutionUnit.Inch); // This is a standard option for JPEG images. // Two chroma components (Cb and Cr) can be bandwidth-reduced, subsampled, compressed. createOptions.setColorType(com.aspose.imaging.fileformats.jpeg.JpegCompressionColorMode.YCbCr); com.aspose.imaging.fileformats.jpeg.JpegImage jpegImage = new com.aspose.imaging.fileformats.jpeg.JpegImage(createOptions, 100, 100); try { com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(jpegImage); com.aspose.imaging.brushes.LinearGradientBrush gradientBrush = new com.aspose.imaging.brushes.LinearGradientBrush( new com.aspose.imaging.Point(0, 0), new com.aspose.imaging.Point(jpegImage.getWidth(), jpegImage.getHeight()), com.aspose.imaging.Color.getYellow(), com.aspose.imaging.Color.getBlue()); // Fill the image with a grayscale gradient graphics.fillRectangle(gradientBrush, jpegImage.getBounds()); // Save to a file. jpegImage.save(dir + "output.explicitoptions.jpg"); } finally { jpegImage.dispose(); }
public final void setResolutionUnit(byte value)
Sets the resolution unit.
value
- the resolution unit.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(); }