Class WebPImage

Class WebPImage

Namespace: Aspose.Imaging.FileFormats.Webp
Assembly: Aspose.Imaging.dll (25.2.0)

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.

[JsonObject(MemberSerialization.OptIn)]
public sealed class WebPImage : RasterCachedMultipageImage, IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage

Inheritance

objectDisposableObjectDataStreamSupporterImageRasterImageRasterCachedImageRasterCachedMultipageImageWebPImage

Implements

IDisposable, IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImageExt, IMultipageImage

Inherited Members

RasterCachedMultipageImage.AdjustBrightness(int), RasterCachedMultipageImage.AdjustContrast(float), RasterCachedMultipageImage.AdjustGamma(float, float, float), RasterCachedMultipageImage.AdjustGamma(float), RasterCachedMultipageImage.Blend(Point, RasterImage, Rectangle, byte), RasterCachedMultipageImage.BinarizeFixed(byte), RasterCachedMultipageImage.BinarizeBradley(double, int), RasterCachedMultipageImage.BinarizeBradley(double), RasterCachedMultipageImage.BinarizeOtsu(), RasterCachedMultipageImage.Crop(Rectangle), RasterCachedMultipageImage.Crop(int, int, int, int), RasterCachedMultipageImage.Dither(DitheringMethod, int, IColorPalette), RasterCachedMultipageImage.Grayscale(), RasterCachedMultipageImage.Rotate(float, bool, Color), RasterCachedMultipageImage.RotateFlip(RotateFlipType), RasterCachedMultipageImage.RotateFlipAll(RotateFlipType), RasterCachedMultipageImage.Resize(int, int, ResizeType), RasterCachedMultipageImage.Resize(int, int, ImageResizeSettings), RasterCachedMultipageImage.ResizeWidthProportionally(int, ResizeType), RasterCachedMultipageImage.ResizeHeightProportionally(int, ResizeType), RasterCachedMultipageImage.ReplaceColor(int, byte, int), RasterCachedMultipageImage.ReplaceNonTransparentColors(int), RasterCachedMultipageImage.Filter(Rectangle, FilterOptionsBase), RasterCachedMultipageImage.NormalizeAngle(bool, Color), RasterCachedMultipageImage.CacheData(), RasterCachedMultipageImage.GetSerializedStream(ImageOptionsBase, Rectangle, out int), RasterCachedMultipageImage.Height, RasterCachedMultipageImage.Width, RasterCachedMultipageImage.BitsPerPixel, RasterCachedMultipageImage.IsCached, RasterCachedMultipageImage.PageCount, RasterCachedMultipageImage.Pages, RasterCachedMultipageImage.HasAlpha, RasterCachedMultipageImage.HasTransparentColor, RasterCachedMultipageImage.ImageOpacity, RasterCachedMultipageImage.BackgroundColor, RasterCachedMultipageImage.XmpData, RasterCachedMultipageImage.PageExportingAction, RasterCachedImage.CacheData(), RasterCachedImage.Blend(Point, RasterImage, Rectangle, byte), RasterCachedImage.Resize(int, int, ResizeType), RasterCachedImage.Resize(int, int, ImageResizeSettings), RasterCachedImage.RotateFlip(RotateFlipType), RasterCachedImage.Rotate(float, bool, Color), RasterCachedImage.Crop(Rectangle), RasterCachedImage.Dither(DitheringMethod, int, IColorPalette), RasterCachedImage.Grayscale(), RasterCachedImage.BinarizeFixed(byte), RasterCachedImage.BinarizeOtsu(), RasterCachedImage.BinarizeBradley(double, int), RasterCachedImage.BinarizeBradley(double), RasterCachedImage.AdjustBrightness(int), RasterCachedImage.AdjustContrast(float), RasterCachedImage.AdjustGamma(float, float, float), RasterCachedImage.AdjustGamma(float), RasterCachedImage.IsCached, RasterImage.RemoveMetadata(), RasterImage.Save(Stream, ImageOptionsBase, Rectangle), RasterImage.GetModifyDate(bool), RasterImage.Dither(DitheringMethod, int), RasterImage.Dither(DitheringMethod, int, IColorPalette), RasterImage.GetDefaultPixels(Rectangle, IPartialArgb32PixelLoader), RasterImage.GetDefaultRawData(Rectangle, IPartialRawDataLoader, RawDataSettings), RasterImage.GetDefaultArgb32Pixels(Rectangle), RasterImage.GetDefaultRawData(Rectangle, RawDataSettings), RasterImage.GetArgb32Pixel(int, int), RasterImage.GetPixel(int, int), RasterImage.SetArgb32Pixel(int, int, int), RasterImage.SetPixel(int, int, Color), RasterImage.ReadScanLine(int), RasterImage.ReadArgb32ScanLine(int), RasterImage.WriteScanLine(int, Color[]), RasterImage.WriteArgb32ScanLine(int, int[]), RasterImage.LoadPartialArgb32Pixels(Rectangle, IPartialArgb32PixelLoader), RasterImage.LoadPartialPixels(Rectangle, IPartialPixelLoader), RasterImage.LoadArgb32Pixels(Rectangle), RasterImage.LoadArgb64Pixels(Rectangle), RasterImage.LoadPartialArgb64Pixels(Rectangle, IPartialArgb64PixelLoader), RasterImage.LoadPixels(Rectangle), RasterImage.LoadCmykPixels(Rectangle), RasterImage.LoadCmyk32Pixels(Rectangle), RasterImage.LoadRawData(Rectangle, RawDataSettings, IPartialRawDataLoader), RasterImage.LoadRawData(Rectangle, Rectangle, RawDataSettings, IPartialRawDataLoader), RasterImage.SaveRawData(byte[], int, Rectangle, RawDataSettings), RasterImage.SaveArgb32Pixels(Rectangle, int[]), RasterImage.SavePixels(Rectangle, Color[]), RasterImage.SaveCmykPixels(Rectangle, CmykColor[]), RasterImage.SaveCmyk32Pixels(Rectangle, int[]), RasterImage.SetResolution(double, double), RasterImage.SetPalette(IColorPalette, bool), RasterImage.Resize(int, int, ImageResizeSettings), RasterImage.Rotate(float, bool, Color), RasterImage.Rotate(float), RasterImage.BinarizeFixed(byte), RasterImage.BinarizeOtsu(), RasterImage.BinarizeBradley(double), RasterImage.BinarizeBradley(double, int), RasterImage.Blend(Point, RasterImage, Rectangle, byte), RasterImage.Blend(Point, RasterImage, byte), RasterImage.Grayscale(), RasterImage.AdjustBrightness(int), RasterImage.AdjustContrast(float), RasterImage.AdjustGamma(float, float, float), RasterImage.AdjustGamma(float), RasterImage.GetSkewAngle(), RasterImage.NormalizeAngle(), RasterImage.NormalizeAngle(bool, Color), RasterImage.Filter(Rectangle, FilterOptionsBase), RasterImage.ReplaceColor(Color, byte, Color), RasterImage.ReplaceColor(int, byte, int), RasterImage.ReplaceNonTransparentColors(Color), RasterImage.ReplaceNonTransparentColors(int), RasterImage.ToBitmap(), RasterImage.PremultiplyComponents, RasterImage.UseRawData, RasterImage.UpdateXmpData, RasterImage.XmpData, RasterImage.RawIndexedColorConverter, RasterImage.RawCustomColorConverter, RasterImage.RawFallbackIndex, RasterImage.RawDataSettings, RasterImage.UsePalette, RasterImage.RawDataFormat, RasterImage.RawLineSize, RasterImage.IsRawDataAvailable, RasterImage.HorizontalResolution, RasterImage.VerticalResolution, RasterImage.HasTransparentColor, RasterImage.HasAlpha, RasterImage.TransparentColor, RasterImage.ImageOpacity, Image.CanLoad(string), Image.CanLoad(string, LoadOptions), Image.CanLoad(Stream), Image.CanLoad(Stream, LoadOptions), Image.Create(ImageOptionsBase, int, int), Image.Create(Image[]), Image.Create(MultipageCreateOptions), Image.Create(string[], bool), Image.Create(string[]), Image.Create(Image[], bool), Image.GetFileFormat(string), Image.GetFileFormat(Stream), Image.GetFittingRectangle(Rectangle, int, int), Image.GetFittingRectangle(Rectangle, int[], int, int), Image.Load(string, LoadOptions), Image.Load(string), Image.Load(Stream, LoadOptions), Image.Load(Stream), Image.GetProportionalWidth(int, int, int), Image.GetProportionalHeight(int, int, int), Image.RemoveMetadata(), Image.CanSave(ImageOptionsBase), Image.Resize(int, int), Image.Resize(int, int, ResizeType), Image.Resize(int, int, ImageResizeSettings), Image.GetDefaultOptions(object[]), Image.GetOriginalOptions(), Image.ResizeWidthProportionally(int), Image.ResizeHeightProportionally(int), Image.ResizeWidthProportionally(int, ResizeType), Image.ResizeHeightProportionally(int, ResizeType), Image.ResizeWidthProportionally(int, ImageResizeSettings), Image.ResizeHeightProportionally(int, ImageResizeSettings), Image.RotateFlip(RotateFlipType), Image.Rotate(float), Image.Crop(Rectangle), Image.Crop(int, int, int, int), Image.Save(), Image.Save(string), Image.Save(string, ImageOptionsBase), Image.Save(string, ImageOptionsBase, Rectangle), Image.Save(Stream, ImageOptionsBase), Image.Save(Stream, ImageOptionsBase, Rectangle), Image.GetSerializedStream(ImageOptionsBase, Rectangle, out int), Image.SetPalette(IColorPalette, bool), Image.BitsPerPixel, Image.Bounds, Image.Container, Image.Height, Image.Palette, Image.UsePalette, Image.Size, Image.Width, Image.InterruptMonitor, Image.BufferSizeHint, Image.AutoAdjustPalette, Image.HasBackgroundColor, Image.FileFormat, Image.BackgroundColor, DataStreamSupporter.CacheData(), DataStreamSupporter.Save(), DataStreamSupporter.Save(Stream), DataStreamSupporter.Save(string), DataStreamSupporter.Save(string, bool), DataStreamSupporter.DataStreamContainer, DataStreamSupporter.IsCached, DisposableObject.Dispose(), DisposableObject.Disposed, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Examples

This example shows how to load a WebP image from a file and save it to PNG.```csharp [C#]

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

                                                                                  // Load a WebP image from a file.
                                                                                  using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
                                                                                  {
                                                                                      // 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 Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

## Constructors

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage__ctor_System_IO_Stream_"></a> WebPImage\(Stream\)

Instantiate a new instance of the Aspose.Imaging.FileFormats.Webp.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.

```csharp
public WebPImage(Stream stream)

Parameters

stream Stream

The stream WebP image.

Examples

This example shows how to load a WebP image from a file stream and save it to PNG.```csharp [C#]

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

                                                                                         // Load a WebP image from a file stream.
                                                                                         using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "test.webp"))
                                                                                         using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(stream))
                                                                                         {
                                                                                             // 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 Aspose.Imaging.ImageOptions.PngOptions());
                                                                                         }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage__ctor_System_IO_Stream_Aspose_Imaging_LoadOptions_"></a> WebPImage\(Stream, LoadOptions\)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.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.

```csharp
public WebPImage(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

The stream WebP image.

loadOptions LoadOptions

The load options.

WebPImage(string)

Instantiate a fresh instance of the Aspose.Imaging.FileFormats.Webp.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.

public WebPImage(string path)

Parameters

path string

The path to file WebP Image

Examples

This example shows how to load a WebP image from a file and save it to PNG.```csharp [C#]

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

                                                                                  // Load a WebP image from a file.
                                                                                  using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
                                                                                  {
                                                                                      // 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 Aspose.Imaging.ImageOptions.PngOptions());
                                                                                  }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage__ctor_System_String_Aspose_Imaging_LoadOptions_"></a> WebPImage\(string, LoadOptions\)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.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.

```csharp
public WebPImage(string path, LoadOptions loadOptions)

Parameters

path string

The path to file WebP Image

loadOptions LoadOptions

The load options.

WebPImage(RasterImage)

Instantiate a new instance of the Aspose.Imaging.FileFormats.Webp.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.

public WebPImage(RasterImage rasterImage)

Parameters

rasterImage RasterImage

The raster image.

Examples

This example shows how to create a WebP image from another raster image.```csharp [C#]

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

                                                                               // Load a PNG image of 100x100 px.
                                                                               using (Aspose.Imaging.FileFormats.Png.PngImage pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
                                                                               {
                                                                                   Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(pngImage);

                                                                                   // Fill the entire image in red.
                                                                                   Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                   graphics.FillRectangle(brush, pngImage.Bounds);

                                                                                   // Create a WebP image based on the PNG image.
                                                                                   using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
                                                                                   {
                                                                                       // Save to a WebP file with default options
                                                                                       webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
                                                                                   }
                                                                               }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage__ctor_Aspose_Imaging_RasterImage_Aspose_Imaging_LoadOptions_"></a> WebPImage\(RasterImage, LoadOptions\)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.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.

```csharp
public WebPImage(RasterImage rasterImage, LoadOptions loadOptions)

Parameters

rasterImage RasterImage

The raster image.

loadOptions LoadOptions

The load options.

WebPImage(int, int, WebPOptions)

Instantiate a new instance of the Aspose.Imaging.FileFormats.Webp.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.

public WebPImage(int width, int height, WebPOptions options)

Parameters

width int

The image width

height int

The image height.

options WebPOptions

The options.

Examples

This example shows how to create a WebP image with the specified options from scratch.```csharp [C#]

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

                                                                                             Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
                                                                                             createOptions.Lossless = true;
                                                                                             createOptions.Quality = 100f;
                                                                                             //createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dir + "output.webp");

                                                                                             // Create a WebP image of 100x100 px.
                                                                                             using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
                                                                                             {
                                                                                                 Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(webPImage);

                                                                                                 // Fill the entire image in red.
                                                                                                 Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                 graphics.FillRectangle(brush, webPImage.Bounds);

                                                                                                 // Save to a WebP file
                                                                                                 webPImage.Save(dir + "output.webp");
                                                                                             }

This example shows how to create a multi-frame animated WebP image with the specified options.```csharp
[C#]

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

                                                                                                         Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
                                                                                                         createOptions.Lossless = true;
                                                                                                         createOptions.Quality = 100f;
                                                                                                         createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();

                                                                                                         // The default frame plus 36 + 36 additional frames.
                                                                                                         createOptions.AnimLoopCount = 36 + 36 + 1;

                                                                                                         // Create a WebP image of 100x100 px.
                                                                                                         using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
                                                                                                         {
                                                                                                             // The first circle is red
                                                                                                             Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

                                                                                                             // The second circle is black
                                                                                                             Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);

                                                                                                             // Gradually inscrease the angle of the red arc shape.
                                                                                                             for (int angle = 10; angle &lt;= 360; angle += 10)
                                                                                                             {
                                                                                                                 Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
                                                                                                                 Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
                                                                                                                 graphics.FillPie(brush1, block.Bounds, 0, angle);

                                                                                                                 webPImage.AddBlock(block);
                                                                                                             }

                                                                                                             // Gradually inscrease the angle of the black arc and wipe out the red arc.
                                                                                                             for (int angle = 10; angle &lt;= 360; angle += 10)
                                                                                                             {
                                                                                                                 Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);

                                                                                                                 Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
                                                                                                                 graphics.FillPie(brush2, block.Bounds, 0, angle);
                                                                                                                 graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);

                                                                                                                 webPImage.AddBlock(block);
                                                                                                             }

                                                                                                             // Save to a WebP file
                                                                                                             webPImage.Save(dir + "output.webp");
                                                                                                         }

WebPImage(int, int, WebPOptions, LoadOptions)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.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.

public WebPImage(int width, int height, WebPOptions options, LoadOptions loadOptions)

Parameters

width int

The image width

height int

The image height.

options WebPOptions

The options.

loadOptions LoadOptions

The load options.

Properties

FileFormat

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.

public override FileFormat FileFormat { get; }

Property Value

FileFormat

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.

public override bool HasAlpha { get; }

Property Value

bool

Examples

The following example loads a WEBP image and prints information about raw data format and alpha channel.```csharp [C#]

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

                                                                                                               string fileName = dir + "sample.webp";
                                                                                                               using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
                                                                                                               {
                                                                                                                   Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (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.Console.WriteLine("ImageFile={0}, FileFormat={1}, HasAlpha={2}", fileName, webpImage.RawDataFormat, webpImage.HasAlpha);

                                                                                                                   int i = 0;
                                                                                                                   foreach (Aspose.Imaging.FileFormats.Webp.IFrame frame in webpImage.Blocks)
                                                                                                                   {
                                                                                                                       Aspose.Imaging.FileFormats.Webp.WebPFrameBlock frameBlock = frame as Aspose.Imaging.FileFormats.Webp.WebPFrameBlock;
                                                                                                                       if (frameBlock != null)
                                                                                                                       {
                                                                                                                           System.Console.WriteLine("Frame={0}, FileFormat={1}, HasAlpha={2}", i++, frameBlock.RawDataFormat, frameBlock.HasAlpha);
                                                                                                                       }
                                                                                                                   }
                                                                                                               }

                                                                                                               // 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

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage_Options"></a> Options

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.

```csharp
[JsonProperty]
public WebPOptions Options { get; }

Property Value

WebPOptions

PageCount

Retrieve the total count of pages within the specified document, facilitating efficient navigation and management of multi-page content. Incorporate this functionality to enhance user experience, enabling seamless access to comprehensive document structures.

public override int PageCount { get; }

Property Value

int

Pages

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.

public override Image[] Pages { get; }

Property Value

Image[]

Methods

AddBlock(IFrame)

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.

public void AddBlock(IFrame block)

Parameters

block IFrame

The Webp block to add.

Examples

This example shows how to create a multi-frame animated WebP image with the specified options.```csharp [C#]

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

                                                                                                     Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
                                                                                                     createOptions.Lossless = true;
                                                                                                     createOptions.Quality = 100f;
                                                                                                     createOptions.AnimBackgroundColor = (uint)Aspose.Imaging.Color.Gray.ToArgb();

                                                                                                     // The default frame plus 36 + 36 additional frames.
                                                                                                     createOptions.AnimLoopCount = 36 + 36 + 1;

                                                                                                     // Create a WebP image of 100x100 px.
                                                                                                     using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
                                                                                                     {
                                                                                                         // The first circle is red
                                                                                                         Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);

                                                                                                         // The second circle is black
                                                                                                         Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);

                                                                                                         // Gradually inscrease the angle of the red arc shape.
                                                                                                         for (int angle = 10; angle &lt;= 360; angle += 10)
                                                                                                         {
                                                                                                             Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
                                                                                                             Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
                                                                                                             graphics.FillPie(brush1, block.Bounds, 0, angle);

                                                                                                             webPImage.AddBlock(block);
                                                                                                         }

                                                                                                         // Gradually inscrease the angle of the black arc and wipe out the red arc.
                                                                                                         for (int angle = 10; angle &lt;= 360; angle += 10)
                                                                                                         {
                                                                                                             Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);

                                                                                                             Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block);
                                                                                                             graphics.FillPie(brush2, block.Bounds, 0, angle);
                                                                                                             graphics.FillPie(brush1, block.Bounds, angle, 360 - angle);

                                                                                                             webPImage.AddBlock(block);
                                                                                                         }

                                                                                                         // Save to a WebP file
                                                                                                         webPImage.Save(dir + "output.webp");
                                                                                                     }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage_AddPage_Aspose_Imaging_RasterImage_"></a> AddPage\(RasterImage\)

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 multi-page 
documents or images.

```csharp
public void AddPage(RasterImage page)

Parameters

page RasterImage

The page to add.

Exceptions

ArgumentNullException

page is null.

AdjustBrightness(int)

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.

public override void AdjustBrightness(int brightness)

Parameters

brightness int

Brightness value.

AdjustContrast(float)

Enhance the contrast of the Aspose.Imaging.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.

public override void AdjustContrast(float contrast)

Parameters

contrast float

Contrast value (in range [-100; 100])

AdjustGamma(float)

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.

public override void AdjustGamma(float gamma)

Parameters

gamma float

Gamma for red, green and blue channels coefficient

AdjustGamma(float, float, float)

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.

public override void AdjustGamma(float gammaRed, float gammaGreen, float gammaBlue)

Parameters

gammaRed float

Gamma for red channel coefficient

gammaGreen float

Gamma for green channel coefficient

gammaBlue float

Gamma for blue channel coefficient

BinarizeBradley(double, int)

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.

public override void BinarizeBradley(double brightnessDifference, int windowSize)

Parameters

brightnessDifference double

The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.

windowSize int

The size of s x s window of pixels centered around this pixel

BinarizeFixed(byte)

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.

public override void BinarizeFixed(byte threshold)

Parameters

threshold byte

Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.

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.

public override void BinarizeOtsu()

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 ClearBlocks()

Crop(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.

public override void Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle.

Crop(int, int, int, int)

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.

public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)

Parameters

leftShift int

The left shift.

rightShift int

The right shift.

topShift int

The top shift.

bottomShift int

The bottom shift.

Dither(DitheringMethod, int, IColorPalette)

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.

public override void Dither(DitheringMethod ditheringMethod, int bitsCount, IColorPalette customPalette)

Parameters

ditheringMethod DitheringMethod

The dithering method.

bitsCount int

The final bits count for dithering.

customPalette IColorPalette

The custom palette for dithering.

Filter(Rectangle, FilterOptionsBase)

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.

public override void Filter(Rectangle rectangle, FilterOptionsBase options)

Parameters

rectangle Rectangle

The rectangle.

options FilterOptionsBase

The options.

Examples

The following example applies various types of filters to a WEBP image.```csharp [C#]

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

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;

                                                                                  // Apply a median filter with a rectangle size of 5 to the entire image.
                                                                                  webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MedianFilterOptions(5));
                                                                                  webpImage.Save(dir + "sample.MedianFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (Aspose.Imaging.FileFormats.Webp.WebPImage)image;

                                                                                  // Apply a bilateral smoothing filter with a kernel size of 5 to the entire image.
                                                                                  webpImage.Filter(webpImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.BilateralSmoothingFilterOptions(5));
                                                                                  webpImage.Save(dir + "sample.BilateralSmoothingFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (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.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
                                                                                  webpImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (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.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
                                                                                  webpImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (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.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.MotionWienerFilterOptions(10, 1.0, 90.0));
                                                                                  webpImage.Save(dir + "sample.MotionWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                              {
                                                                                  Aspose.Imaging.FileFormats.Webp.WebPImage webpImage = (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.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
                                                                                  webpImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                              }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage_Grayscale"></a> Grayscale\(\)

Convert the image to its grayscale representation, transforming it into a 
single-channel image where each pixel represents intensity or luminance. Integrate 
this method into your image processing pipeline to simplify analysis and enhance 
compatibility with grayscale-based algorithms, facilitating various computer 
vision and image analysis tasks within your application.

```csharp
public override void Grayscale()

InsertBlock(int, IFrame)

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.

public void InsertBlock(int index, IFrame block)

Parameters

index int

The zero-based element, at which block will be inserted.

block IFrame

The Webp block to add.

ReleaseManagedResources()

Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.

protected override void ReleaseManagedResources()

RemoveBlock(IFrame)

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.

public void RemoveBlock(IFrame block)

Parameters

block IFrame

The block to remove.

Remarks

Note: do not forget to Dispose the block if you will not add it to some other WebPImage.

Resize(int, 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.

public override void Resize(int newWidth, int newHeight, ResizeType resizeType)

Parameters

newWidth int

The new width.

newHeight int

The new height.

resizeType ResizeType

The resize type.

Examples

This example loads a WEBP image and resizes it using various resizing methods.```csharp [C#]

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

                                                                                     using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                                     {
                                                                                         // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                         image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                         // Save to PNG with default options.
                                                                                         image.Save(dir + "upsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                     }

                                                                                     using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                                     {
                                                                                         // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                         image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);

                                                                                         // Save to PNG with default options.
                                                                                         image.Save(dir + "downsample.nearestneighbour.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                     }

                                                                                     using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                                     {
                                                                                         // Scale up by 2 times using Bilinear resampling.
                                                                                         image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                         // Save to PNG with default options.
                                                                                         image.Save(dir + "upsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                     }

                                                                                     using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
                                                                                     {
                                                                                         // Scale down by 2 times using Bilinear resampling.
                                                                                         image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);

                                                                                         // Save to PNG with default options.
                                                                                         image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                     }

### <a id="Aspose_Imaging_FileFormats_Webp_WebPImage_Resize_System_Int32_System_Int32_Aspose_Imaging_ImageResizeSettings_"></a> Resize\(int, int, ImageResizeSettings\)

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.

```csharp
public override void Resize(int newWidth, int newHeight, ImageResizeSettings settings)

Parameters

newWidth int

The new width.

newHeight int

The new height.

settings ImageResizeSettings

The resize settings.

ResizeHeightProportionally(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.

public override void ResizeHeightProportionally(int newHeight, ResizeType resizeType)

Parameters

newHeight int

The new height.

resizeType ResizeType

Type of the resize.

ResizeWidthProportionally(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.

public override void ResizeWidthProportionally(int newWidth, ResizeType resizeType)

Parameters

newWidth int

The new width.

resizeType ResizeType

Type of the resize.

Rotate(float, bool, Color)

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.

public override void Rotate(float angle, bool resizeProportionally, Color backgroundColor)

Parameters

angle float

The rotate angle in degrees. Positive values will rotate clockwise.

resizeProportionally bool

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 internal image contents are rotated.

backgroundColor Color

Color of the background.

RotateFlip(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.

public override void RotateFlip(RotateFlipType rotateFlipType)

Parameters

rotateFlipType RotateFlipType

The rotate flip type.

SaveData(Stream)

Saves the data.

protected override void SaveData(Stream stream)

Parameters

stream Stream

The stream to save data to.

UpdateDimensions(int, int)

Updates the image dimensions.

protected override void UpdateDimensions(int newWidth, int newHeight)

Parameters

newWidth int

The new image width.

newHeight int

The new image height.