public final class WebPImage extends RasterCachedMultipageImage implements IMultipageImageExt
Manipulate WebP raster images with our API, using its modern features for both lossless and lossy compression, ensuring optimal image quality with reduced file sizes. Seamlessly handle extended file formats, animations, and alpha channels, while easily updating dimensions, resizing proportionally, cropping, rotating, applying filters, adjusting image parameters, and converting to other image formats for versatile web image optimization.
This example shows how to load a WebP image from a file and save it to PNG.
String dir = "c:\\temp\\";
// Load a WebP image from a file.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(dir + "test.webp");
try {
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.save(dir + "test.output.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
webPImage.dispose();
}
| Constructor and Description |
|---|
WebPImage(InputStream stream)
Instantiate a new instance of the
WebPImage class, initialized
from a provided stream source. |
WebPImage(InputStream stream,
LoadOptions loadOptions)
Create a new instance of the
WebPImage class using a stream and
specified load options, facilitating versatile handling of WebP image data. |
WebPImage(int width,
int height,
WebPOptions options)
Instantiate a new instance of the
WebPImage class with an empty
image of specified width and height dimensions. |
WebPImage(int width,
int height,
WebPOptions options,
LoadOptions loadOptions)
Create a new instance of the
WebPImage class with an empty image and specified
load options. |
WebPImage(RasterImage rasterImage)
Instantiate a new instance of the
WebPImage class, initialized
from a provided rasterImage object. |
WebPImage(RasterImage rasterImage,
LoadOptions loadOptions)
Create a new instance of the
WebPImage class using a rasterImage object and
specified load options, enabling flexible handling of image data. |
WebPImage(String path)
Instantiate a fresh instance of the
WebPImage class, initialized
from a provided file source. |
WebPImage(String path,
LoadOptions loadOptions)
Create a new instance of the
WebPImage class using a file and
specified load options, facilitating flexible handling of WebP image data. |
| Modifier and Type | Method and Description |
|---|---|
void |
addBlock(IFrame block)
Incorporate a new WebP block into the image, enriching its content and
facilitating advanced image manipulation.
|
void |
addPage(RasterImage page)
Append a new page to the image, expanding its content and accommodating additional
visual elements.
|
void |
adjustBrightness(int brightness)
Implement
brightness adjustment for the image, allowing the
modification of overall luminance levels. |
void |
adjustContrast(float contrast)
Enhance the contrast of the
Image, amplifying the
differences between light and dark areas. |
void |
adjustGamma(float gamma)
Apply gamma correction to the image, adjusting pixel intensities to achieve
desired brightness and color balance.
|
void |
adjustGamma(float gammaRed,
float gammaGreen,
float gammaBlue)
Perform gamma correction on the image using individual coefficients for the red,
green, and blue channels, allowing for fine-tuned adjustments of color balance and
contrast.
|
void |
binarizeBradley(double brightnessDifference,
int windowSize)
Apply binarization to the image using Bradley's adaptive thresholding algorithm
with integral image thresholding.
|
void |
binarizeFixed(byte threshold)
Perform binarization on the image using a predefined threshold value, converting
it into a binary image where pixels are classified as foreground or background
based on their intensity relative to the threshold.
|
void |
binarizeOtsu()
Perform binarization on the image using Otsu's thresholding method, automatically
determining the optimal threshold value based on the image's histogram.
|
void |
clearBlocks()
Clear all existing WebP blocks from the image, facilitating a clean slate for
subsequent modifications or additions.
|
void |
crop(int leftShift,
int rightShift,
int topShift,
int bottomShift)
Crop the image by applying left, right, top, and bottom shifts, effectively
selecting a region of interest within the image.
|
void |
crop(Rectangle rectangle)
Crop the image using a specified rectangle region, removing unwanted portions
while retaining the desired content.
|
void |
dither(int ditheringMethod,
int bitsCount,
IColorPalette customPalette)
Perform dithering on the current image to reduce color banding and enhance visual
quality.
|
void |
filter(Rectangle rectangle,
FilterOptionsBase options)
Filter the content within the specified rectangle, applying a designated image
processing filter to enhance or modify the selected region.
|
long |
getFileFormat()
Access the file format value associated with the image, providing information
about the format in which the image is stored.
|
WebPOptions |
getOptions()
Retrieve or modify the options associated with the specified property, enabling
fine-tuned customization of behavior and settings.
|
int |
getPageCount()
Retrieve the total count of pages within the specified document, facilitating
efficient navigation and management of multipage content.
|
Image[] |
getPages()
Access the WebP blocks within the image, allowing detailed examination or
manipulation of the underlying block structure.
|
void |
grayscale()
Apply binarization to the image using Bradley's adaptive thresholding algorithm
with integral image thresholding.
|
boolean |
hasAlpha()
Retrieve whether the image contains an alpha channel, indicating the presence of
transparency information.
|
void |
insertBlock(int index,
IFrame block)
Insert a new WebP block at the specified index within the image, enabling precise
control over the block sequence.
|
void |
removeBlock(IFrame block)
Remove the specified WebP block from the image, facilitating efficient management
of image data structure.
|
void |
resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resize the image according to specified settings, enabling precise control over
dimensions, aspect ratio, and scaling behavior.
|
void |
resize(int newWidth,
int newHeight,
int resizeType)
Resize the image, adjusting its dimensions while preserving the aspect ratio.
|
void |
resizeHeightProportionally(int newHeight,
int resizeType)
Adjust the height of the image proportionally, while preserving its aspect ratio
for consistent resizing.
|
void |
resizeWidthProportionally(int newWidth,
int resizeType)
Proportionally adjust the width of the image while maintaining its aspect ratio.
|
void |
rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
Rotate the image around its center by a specified angle, while proportionally
resizing it and applying specified background color parameters.
|
void |
rotateFlip(int rotateFlipType)
Apply rotation, flipping, or both operations exclusively to the active frame
within the image.
|
analyzePercentageDigitalSignature, binarizeBradley, blend, cacheData, embedDigitalSignature, getBackgroundColor, getBitsPerPixel, getHeight, getImageOpacity, getPageExportingAction, getWidth, getXmpData, hasTransparentColor, isCached, isDigitalSigned, normalizeAngle, normalizeHistogram, replaceColor, replaceNonTransparentColors, rotateFlipAll, setBackgroundColor, setPageExportingAction, setXmpDataautoBrightnessContrastblend, blend, blend, dither, getArgb32Pixel, getDefaultArgb32Pixels, getDefaultPixels, getDefaultRawData, getDefaultRawData, getHorizontalResolution, getModifyDate, getPixel, getPremultiplyComponents, getRawCustomColorConverter, getRawDataFormat, getRawDataSettings, getRawFallbackIndex, getRawIndexedColorConverter, getRawLineSize, getSkewAngle, getTransparentColor, getUpdateXmpData, getUseRawData, getVerticalResolution, isDigitalSigned, isRawDataAvailable, isUsePalette, loadArgb32Pixels, loadArgb64Pixels, loadCmyk32Pixels, loadCmykPixels, loadPartialArgb32Pixels, loadPartialArgb64Pixels, loadPartialPixels, loadPixels, loadRawData, loadRawData, normalizeAngle, readArgb32ScanLine, readScanLine, removeMetadata, replaceColor, replaceNonTransparentColors, rotate, saveArgb32Pixels, saveCmyk32Pixels, saveCmykPixels, savePixels, saveRawData, setArgb32Pixel, setHorizontalResolution, setPalette, setPixel, setPremultiplyComponents, setRawCustomColorConverter, setRawFallbackIndex, setRawIndexedColorConverter, setResolution, setTransparentColor, setTransparentColor, setUpdateXmpData, setUseRawData, setVerticalResolution, toBitmap, writeArgb32ScanLine, writeScanLinecanLoad, canLoad, canLoad, canLoad, canSave, create, create, create, create, create, create, getBounds, getBufferSizeHint, getContainer, getDefaultOptions, getFileFormat, getFileFormat, getFittingRectangle, getFittingRectangle, getInterruptMonitor, getIProgressEventHandler, getOriginalOptions, getPalette, getProgressEventHandlerInfo, getProportionalHeight, getProportionalWidth, getSerializedStream, getSize, hasBackgroundColor, isAutoAdjustPalette, load, load, load, load, load, load, resize, resizeHeightProportionally, resizeHeightProportionally, resizeWidthProportionally, resizeWidthProportionally, save, save, save, save, save, save, save, save, setAutoAdjustPalette, setBackgroundColor, setBufferSizeHint, setInterruptMonitor, setPalettegetDataStreamContainer, save, save, saveclose, dispose, getDisposedequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPageExportingAction, setPageExportingActionpublic WebPImage(InputStream stream)
Instantiate a new instance of the WebPImage class, initialized
from a provided stream source. Utilize this constructor to seamlessly create WebP
image objects directly from streams, enabling efficient handling and manipulation
of WebP image data within your application.
stream - The stream WebP image.This example shows how to load a WebP image from a file stream and save it to PNG.
String dir = "c:\\temp\\";
// Load a WebP image from a file stream.
java.io.InputStream stream = new java.io.FileInputStream(dir + "test.webp");
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(stream);
try {
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.save(dir + "test.output.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
webPImage.dispose();
}
public WebPImage(InputStream stream, LoadOptions loadOptions)
Create a new instance of the WebPImage class using a stream and
specified load options, facilitating versatile handling of WebP image data.
Incorporate this constructor to seamlessly initialize WebP image objects from
streams while customizing loading parameters as needed within your application.
stream - The stream WebP image.loadOptions - The load options.public WebPImage(String path)
Instantiate a fresh instance of the WebPImage class, initialized
from a provided file source. Utilize this constructor to seamlessly create WebP
image objects directly from files, streamlining the process of loading and
manipulating WebP image data within your application.
path - The path to file WebP ImageThis example shows how to load a WebP image from a file and save it to PNG.
String dir = "c:\\temp\\";
// Load a WebP image from a file.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(dir + "test.webp");
try {
// Save to PNG
// Note that only the active frame will be stored to PNG, since PNG is not a multi-page format.
webPImage.save(dir + "test.output.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
webPImage.dispose();
}
public WebPImage(String path, LoadOptions loadOptions)
Create a new instance of the WebPImage class using a file and
specified load options, facilitating flexible handling of WebP image data. Utilize
this constructor to seamlessly initialize WebP image objects from files while
customizing loading parameters according to your application's requirements.
path - The path to file WebP ImageloadOptions - The load options.public WebPImage(RasterImage rasterImage)
Instantiate a new instance of the WebPImage class, initialized
from a provided rasterImage object. This constructor allows for seamless
conversion of raster images to WebP format, enabling efficient handling and
manipulation of image data within your application.
rasterImage - The raster image.This example shows how to create a WebP image from another raster image.
String dir = "c:\\temp\\";
// Load 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());
// Create a WebP image based on the PNG image.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(pngImage);
try {
// Save to a WebP file with default options
webPImage.save(dir + "output.webp", new com.aspose.imaging.imageoptions.WebPOptions());
} finally {
webPImage.dispose();
}
} finally {
pngImage.dispose();
}
public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)
Create a new instance of the WebPImage class using a rasterImage object and
specified load options, enabling flexible handling of image data. Utilize this
constructor to seamlessly initialize WebP image objects from raster images while
customizing loading parameters according to your application's requirements.
rasterImage - The raster image.loadOptions - The load options.public WebPImage(int width,
int height,
WebPOptions options)
Instantiate a new instance of the WebPImage class with an empty
image of specified width and height dimensions. This constructor allows for the
creation of blank WebP images, providing a foundation for subsequent image
manipulation and content generation within your application.
width - The image widthheight - The image height.options - The options.This example shows how to create a WebP image with the specified options from scratch.
String dir = "c:\\temp\\";
com.aspose.imaging.imageoptions.WebPOptions createOptions = new com.aspose.imaging.imageoptions.WebPOptions();
createOptions.setLossless(true);
createOptions.setQuality(100f);
//createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.webp");
// Create a WebP image of 100x100 px.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(100, 100, createOptions);
try {
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(webPImage);
// 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, webPImage.getBounds());
// Save to a WebP file
webPImage.save(dir + "output.webp");
} finally {
webPImage.dispose();
}
public WebPImage(int width,
int height,
WebPOptions options,
LoadOptions loadOptions)
Create a new instance of the WebPImage class with an empty image and specified
load options. This constructor allows for the initialization of WebP images with
customizable loading parameters, providing flexibility in image creation and
manipulation within your application.
width - The image widthheight - The image height.options - The options.loadOptions - The load options.public WebPOptions getOptions()
Retrieve or modify the options associated with the specified property, enabling fine-tuned customization of behavior and settings. Utilize this property to seamlessly access and manipulate configurable parameters, facilitating versatile control and optimization within your application's functionality.
public Image[] getPages()
Access the WebP blocks within the image, allowing detailed examination or manipulation of the underlying block structure. Utilize this property to analyze or modify individual blocks within the WebP image data, facilitating advanced image processing techniques within your application.
getPages in interface IMultipageImagegetPages in class RasterCachedMultipageImagepublic int getPageCount()
Retrieve the total count of pages within the specified document, facilitating efficient navigation and management of multipage content. Incorporate this functionality to enhance user experience, enabling seamless access to comprehensive document structures.
getPageCount in interface IMultipageImagegetPageCount in class RasterCachedMultipageImagepublic long getFileFormat()
Access the file format value associated with the image, providing information about the format in which the image is stored. Utilize this property to determine the file format of the image, facilitating compatibility checks and format-specific processing within your application.
getFileFormat in class ImageFileFormatpublic boolean hasAlpha()
Retrieve whether the image contains an alpha channel, indicating the presence of transparency information. Utilize this property to determine whether the image includes transparency, enabling appropriate handling and processing of alpha-related operations within your application.
hasAlpha in class RasterCachedMultipageImagetrue if there is an alpha channel.The following example loads a WEBP image and prints information about raw data format and alpha channel.
String dir = "c:\\temp\\";
String fileName = dir + "sample.webp";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(fileName);
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// If the active TIFF frame has alpha channel, then the entire TIFF image is considered to have alpha channel.
System.out.printf("ImageFile=%s, FileFormat=%s, HasAlpha=%s\r\n", fileName, webpImage.getRawDataFormat(), webpImage.hasAlpha());
int i = 0;
for (com.aspose.imaging.fileformats.webp.IFrame frame : webpImage.getBlocks()) {
if (frame instanceof com.aspose.imaging.fileformats.webp.WebPFrameBlock) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock frameBlock = (com.aspose.imaging.fileformats.webp.WebPFrameBlock) frame;
System.out.printf("Frame=%s, FileFormat=%s, HasAlpha=%s\r\n", i++, frameBlock.getRawDataFormat(), frameBlock.hasAlpha());
}
}
} finally {
image.dispose();
}
// The output may look like this:
// ImageFile=c:\temp\sample.webp, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
// Frame=0, FileFormat=RgbIndexed1Bpp, used channels: 1, HasAlpha=False
public void addPage(RasterImage page)
Append a new page to the image, expanding its content and accommodating additional visual elements. Integrate this method to facilitate dynamic page management within your application, enabling seamless creation and augmentation of multipage documents or images.
addPage in interface IMultipageImageExtpage - The page to add.com.aspose.ms.System.ArgumentNullException - page is null.public void addBlock(IFrame block)
Incorporate a new WebP block into the image, enriching its content and facilitating advanced image manipulation. Integrate this method to dynamically enhance the structure and complexity of the WebP image data within your application, enabling precise control and optimization of image rendering.
block - The Webp block to add.This example shows how to create a multi-frame animated WebP image with the specified options.
String dir = "c:\\temp\\";
com.aspose.imaging.imageoptions.WebPOptions createOptions = new com.aspose.imaging.imageoptions.WebPOptions();
createOptions.setLossless(true);
createOptions.setQuality(100f);
createOptions.setAnimBackgroundColor((long) com.aspose.imaging.Color.getGray().toArgb());
// The default frame plus 36 + 36 additional frames.
createOptions.setAnimLoopCount(36 + 36 + 1);
// Create a WebP image of 100x100 px.
com.aspose.imaging.fileformats.webp.WebPImage webPImage = new com.aspose.imaging.fileformats.webp.WebPImage(100, 100, createOptions);
try {
// The first circle is red
com.aspose.imaging.brushes.SolidBrush brush1 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getRed());
// The second circle is black
com.aspose.imaging.brushes.SolidBrush brush2 = new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getBlack());
// Gradually increase the angle of the red arc shape.
for (int angle = 10; angle <= 360; angle += 10) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock block = new com.aspose.imaging.fileformats.webp.WebPFrameBlock(100, 100);
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(block);
graphics.fillPie(brush1, block.getBounds(), 0, angle);
webPImage.addBlock(block);
}
// Gradually increase the angle of the black arc and wipe out the red arc.
for (int angle = 10; angle <= 360; angle += 10) {
com.aspose.imaging.fileformats.webp.WebPFrameBlock block = new com.aspose.imaging.fileformats.webp.WebPFrameBlock(100, 100);
com.aspose.imaging.Graphics graphics = new com.aspose.imaging.Graphics(block);
graphics.fillPie(brush2, block.getBounds(), 0, angle);
graphics.fillPie(brush1, block.getBounds(), angle, 360 - angle);
webPImage.addBlock(block);
}
// Save to a WebP file
webPImage.save(dir + "output.webp");
} finally {
webPImage.dispose();
}
public void clearBlocks()
Clear all existing WebP blocks from the image, facilitating a clean slate for subsequent modifications or additions. Utilize this method to effectively reset the block structure within the WebP image data, ensuring optimal management and organization of image content within your application.
public void insertBlock(int index,
IFrame block)
Insert a new WebP block at the specified index within the image, enabling precise control over the block sequence. Integrate this method to seamlessly incorporate additional WebP blocks into the image data structure, facilitating advanced image processing and optimization within your application.
index - The zero-based element, at which block will be
inserted.block - The Webp block to add.public void removeBlock(IFrame block)
Remove the specified WebP block from the image, facilitating efficient management of image data structure. Utilize this method to streamline image processing workflows by eliminating unnecessary blocks or components within your application.
block - The block to remove.
Note: do not forget to Dispose the block if you
will not add it to some other WebPImage.
public void rotate(float angle,
boolean resizeProportionally,
Color backgroundColor)
Rotate the image around its center by a specified angle, while proportionally resizing it and applying specified background color parameters. Incorporate this method into your image processing workflow to achieve precise transformations with customizable background colors, ensuring optimal visual presentation within your application.
rotate in class RasterCachedMultipageImageangle - The rotation angle in degrees. Positive values will rotate clockwise.resizeProportionally - if set to true you will have your image size changed
according to rotated rectangle (corner points) projections in other
case that leaves dimensions untouched and only
image contents are rotated.backgroundColor - Color of the background.public void resize(int newWidth,
int newHeight,
int resizeType)
Resize the image, adjusting its dimensions while preserving the aspect ratio. Integrate this method into your image processing workflow to dynamically scale images to fit various display or storage requirements within your application.
resize in class RasterCachedMultipageImagenewWidth - The new width.newHeight - The new height.resizeType - The resize type.ResizeTypeThis example loads a WEBP image and resizes it using various resizing methods.
String dir = "c:\\temp\\";
com.aspose.imaging.fileformats.webp.WebPImage image = (com.aspose.imaging.fileformats.webp.WebPImage) com.aspose.imaging.Image.load(dir + "sample.webp");
try {
// Scale up by 2 times using Nearest Neighbour resampling.
image.resize(image.getWidth() * 2, image.getHeight() * 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.save(dir + "upsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.webp.WebPImage) com.aspose.imaging.Image.load(dir + "sample.webp");
try {
// Scale down by 2 times using Nearest Neighbour resampling.
image.resize(image.getWidth() / 2, image.getHeight() / 2, com.aspose.imaging.ResizeType.NearestNeighbourResample);
// Save to PNG with default options.
image.save(dir + "downsample.nearestneighbour.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.webp.WebPImage) com.aspose.imaging.Image.load(dir + "sample.webp");
try {
// Scale up by 2 times using Bilinear resampling.
image.resize(image.getWidth() * 2, image.getHeight() * 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.save(dir + "upsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = (com.aspose.imaging.fileformats.webp.WebPImage) com.aspose.imaging.Image.load(dir + "sample.webp");
try {
// Scale down by 2 times using Bilinear resampling.
image.resize(image.getWidth() / 2, image.getHeight() / 2, com.aspose.imaging.ResizeType.BilinearResample);
// Save to PNG with default options.
image.save(dir + "downsample.bilinear.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void resizeWidthProportionally(int newWidth,
int resizeType)
Proportionally adjust the width of the image while maintaining its aspect ratio. Integrate this method into your image processing workflow to dynamically resize images with consistent proportions, ensuring optimal display or storage within your application.
resizeWidthProportionally in class RasterCachedMultipageImagenewWidth - The new width.resizeType - Type of the resize.ResizeTypepublic void resizeHeightProportionally(int newHeight,
int resizeType)
Adjust the height of the image proportionally, while preserving its aspect ratio for consistent resizing. Integrate this method into your image processing workflow to dynamically resize images with uniform proportions, ensuring optimal display or storage within your application.
resizeHeightProportionally in class RasterCachedMultipageImagenewHeight - The new height.resizeType - Type of the resize.ResizeTypepublic void rotateFlip(int rotateFlipType)
Apply rotation, flipping, or both operations exclusively to the active frame within the image. Integrate this method into your image processing workflow to achieve precise manipulation of individual frames, enhancing flexibility and control over frame transformations within your application.
rotateFlip in class RasterCachedMultipageImagerotateFlipType - The rotation flip type.RotateFlipTypepublic void dither(int ditheringMethod,
int bitsCount,
IColorPalette customPalette)
Perform dithering on the current image to reduce color banding and enhance visual quality. Integrate this method into your image processing workflow to achieve smoother transitions between colors and improve the overall appearance of the image within your application.
dither in class RasterCachedMultipageImageditheringMethod - The dithering method.bitsCount - The final bits count for dithering.customPalette - The custom palette for dithering.DitheringMethodpublic void crop(Rectangle rectangle)
Crop the image using a specified rectangle region, removing unwanted portions while retaining the desired content. Integrate this method into your image processing workflow to precisely extract and focus on specific areas of interest within the image, enhancing clarity and composition for various applications.
crop in class RasterCachedMultipageImagerectangle - The rectangle.public void crop(int leftShift,
int rightShift,
int topShift,
int bottomShift)
Crop the image by applying left, right, top, and bottom shifts, effectively selecting a region of interest within the image. Utilize this method to dynamically extract desired portions of the image while adjusting its composition and focus according to your application's requirements.
crop in class RasterCachedMultipageImageleftShift - The left shift.rightShift - The right shift.topShift - The top shift.bottomShift - The bottom shift.public void binarizeFixed(byte threshold)
Perform binarization on the image using a predefined threshold value, converting it into a binary image where pixels are classified as foreground or background based on their intensity relative to the threshold. Integrate this method into your image processing workflow to facilitate segmentation and feature extraction tasks, enhancing the accuracy and efficiency of subsequent analysis within your application.
binarizeFixed in class RasterCachedMultipageImagethreshold - Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of
(byte)255 will be assigned to it, 0 otherwise.public void binarizeOtsu()
Perform binarization on the image using Otsu's thresholding method, automatically determining the optimal threshold value based on the image's histogram. Integrate this method into your image processing workflow to achieve effective segmentation and feature extraction, enhancing the accuracy and reliability of image analysis tasks within your application.
binarizeOtsu in class RasterCachedMultipageImagepublic void binarizeBradley(double brightnessDifference,
int windowSize)
Apply binarization to the image using Bradley's adaptive thresholding algorithm with integral image thresholding. This method dynamically computes local thresholds based on the image's neighborhood, enhancing adaptability to varying lighting conditions and ensuring robust segmentation for subsequent processing tasks within your application.
binarizeBradley in class RasterCachedMultipageImagebrightnessDifference - The brightness difference between pixel and the average of an s x s window of pixels
centered around this pixel.windowSize - The size of s x s window of pixels centered around this pixelpublic void grayscale()
Apply binarization to the image using Bradley's adaptive thresholding algorithm with integral image thresholding. This method dynamically computes local thresholds based on the image's neighborhood, enhancing adaptability to varying lighting conditions and ensuring robust segmentation for subsequent processing tasks within your application.
grayscale in class RasterCachedMultipageImagepublic void adjustGamma(float gamma)
Apply gamma correction to the image, adjusting pixel intensities to achieve desired brightness and color balance. Incorporate this method into your image processing workflow to enhance visual quality and improve the accuracy of subsequent analysis or display tasks within your application.
adjustGamma in class RasterCachedMultipageImagegamma - Gamma for red, green and blue channels coefficientpublic void adjustGamma(float gammaRed,
float gammaGreen,
float gammaBlue)
Perform gamma correction on the image using individual coefficients for the red, green, and blue channels, allowing for fine-tuned adjustments of color balance and contrast. Integrate this method into your image processing pipeline to achieve precise control over color rendering and enhance visual fidelity within your application.
adjustGamma in class RasterCachedMultipageImagegammaRed - Gamma for red channel coefficientgammaGreen - Gamma for green channel coefficientgammaBlue - Gamma for blue channel coefficientpublic void adjustBrightness(int brightness)
Implement brightness adjustment for the image, allowing the
modification of overall luminance levels. Incorporate this method into your image
processing workflow to enhance visibility and improve the visual quality of images
within your application.
adjustBrightness in class RasterCachedMultipageImagebrightness - Brightness value.public void adjustContrast(float contrast)
Enhance the contrast of the Image, amplifying the
differences between light and dark areas. Integrate this method into your image
processing workflow to improve visual clarity and overall image quality within
your application.
adjustContrast in class RasterCachedMultipageImagecontrast - Contrast value (in range [-100; 100])public void filter(Rectangle rectangle, FilterOptionsBase options)
Filter the content within the specified rectangle, applying a designated image processing filter to enhance or modify the selected region. Integrate this method into your image manipulation workflow to achieve targeted enhancements or transformations within your application.
filter in class RasterCachedMultipageImagerectangle - The rectangle.options - The options.The following example applies various types of filters to a WEBP image.
String dir = "c:\\temp\\";
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a median filter with a rectangle size of 5 to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MedianFilterOptions(5));
webpImage.save(dir + "sample.MedianFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.BilateralSmoothingFilterOptions(5));
webpImage.save(dir + "sample.BilateralSmoothingFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussianBlurFilterOptions(5, 4.0));
webpImage.save(dir + "sample.GaussianBlurFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.GaussWienerFilterOptions(5, 4.0));
webpImage.save(dir + "sample.GaussWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a motion wiener filter with a length of 5, a smooth value of 4.0 and an angle of 90.0 degrees to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.MotionWienerFilterOptions(10, 1.0, 90.0));
webpImage.save(dir + "sample.MotionWienerFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
image = com.aspose.imaging.Image.load(dir + "sample.webp");
try {
com.aspose.imaging.fileformats.webp.WebPImage webpImage = (com.aspose.imaging.fileformats.webp.WebPImage) image;
// Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
webpImage.filter(webpImage.getBounds(), new com.aspose.imaging.imagefilters.filteroptions.SharpenFilterOptions(5, 4.0));
webpImage.save(dir + "sample.SharpenFilter.png", new com.aspose.imaging.imageoptions.PngOptions());
} finally {
image.dispose();
}
public void resize(int newWidth,
int newHeight,
ImageResizeSettings settings)
Resize the image according to specified settings, enabling precise control over dimensions, aspect ratio, and scaling behavior. Integrate this method into your image processing workflow to achieve customized resizing operations tailored to the specific requirements of your application.
resize in class RasterCachedMultipageImagenewWidth - The new width.newHeight - The new height.settings - The resize settings.Copyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.