Class WebPImage

Class WebPImage

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

Manipulate WebP raster images with our API, using its modern features for bothlossless and lossy compression, ensuring optimal image quality with reduced file sizes.Seamlessly handle extended file formats, animations, and alpha channels, while easilyupdating dimensions, resizing proportionally, cropping, rotating, applying filters,adjusting image parameters, and converting to other image formats for versatileweb image optimization.

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

Inheritance

object DisposableObject DataStreamSupporter Image RasterImage RasterCachedImage RasterCachedMultipageImage WebPImage

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.NormalizeHistogram() , 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.NormalizeHistogram() , 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.NormalizeHistogram() , 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.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
   {
       webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
   }

Constructors

WebPImage(Stream)

Instantiate a new instance of the Aspose.Imaging.FileFormats.Webp.WebPImage class, initializedfrom a provided stream source. Utilize this constructor to seamlessly create WebPimage objects directly from streams, enabling efficient handling and manipulationof WebP image data within your application.

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.

string dir = "c:\\temp\\";
   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))
       {
           webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
       }
   }

WebPImage(Stream, LoadOptions)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.WebPImage class using a stream andspecified load options, facilitating versatile handling of WebP image data.Incorporate this constructor to seamlessly initialize WebP image objects fromstreams while customizing loading parameters as needed within your application.

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, initializedfrom a provided file source. Utilize this constructor to seamlessly create WebPimage objects directly from files, streamlining the process of loading andmanipulating WebP image data within your application.

public WebPImage(string path)
{
}
Note that since you provided only a single line of code, it is already properly indented and formatted. However, if there were multiple lines within the method body, I would have reformatted them accordingly following standard C# conventions (i.e., consistent spacing and indentation).

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.

string dir = "c:\\temp\\";
   using (var webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(dir + "test.webp"))
   {
       webPImage.Save(dir + "test.output.png", new Aspose.Imaging.ImageOptions.PngOptions());
   }

WebPImage(string, LoadOptions)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.WebPImage class using a file andspecified load options, facilitating flexible handling of WebP image data. Utilizethis constructor to seamlessly initialize WebP image objects from files whilecustomizing loading parameters according to your application’s requirements.

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, initializedfrom a provided rasterImage object. This constructor allows for seamlessconversion of raster images to WebP format, enabling efficient handling andmanipulation 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.

string dir = "c:\\temp\\";
   using (var pngImage = new Aspose.Imaging.FileFormats.Png.PngImage(100, 100))
   {
       var graphics = new Aspose.Imaging.Graphics(pngImage);
       var brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
       graphics.FillRectangle(brush, pngImage.Bounds);
       using (var webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(pngImage))
       {
           webPImage.Save(dir + "output.webp", new Aspose.Imaging.ImageOptions.WebPOptions());
       }
   }

WebPImage(RasterImage, LoadOptions)

Create a new instance of the Aspose.Imaging.FileFormats.Webp.WebPImage class using a rasterImage object andspecified load options, enabling flexible handling of image data. Utilize thisconstructor to seamlessly initialize WebP image objects from raster images whilecustomizing loading parameters according to your application’s requirements.

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 emptyimage of specified width and height dimensions. This constructor allows for thecreation of blank WebP images, providing a foundation for subsequent imagemanipulation 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.

string dir = "c:\\temp\\";
   Aspose.Imaging.ImageOptions.WebPOptions createOptions = new Aspose.Imaging.ImageOptions.WebPOptions();
   createOptions.Lossless = true;
   createOptions.Quality = 100f;
   using (var webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
   {
       var graphics = new Aspose.Imaging.Graphics(webPImage);
       var brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
       graphics.FillRectangle(brush, webPImage.Bounds);
       webPImage.Save(dir + "output.webp");
   }

This example shows how to create a multi-frame animated WebP image with the specified options.

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();
   createOptions.AnimLoopCount = 36 + 36 + 1;
   using (var webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
   {
      Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
      Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
      for (int angle = 10; angle <= 360; angle += 10)
      {
         Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
         using (Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(block))
         {
            graphics.FillPie(brush1, block.Bounds, 0, angle);
            webPImage.AddBlock(block);
         }
         for (int angle2 = 10; angle2 <= 360; angle2 += 10)
         {
            Aspose.Imaging.FileFormats.Webp.WebPFrameBlock block2 = new Aspose.Imaging.FileFormats.Webp.WebPFrameBlock(100, 100);
            using (Aspose.Imaging.Graphics graphics2 = new Aspose.Imaging.Graphics(block2))
            {
               graphics2.FillPie(brush2, block2.Bounds, 0, angle2);
               graphics2.FillPie(brush1, block2.Bounds, angle2, 360 - angle2);
               webPImage.AddBlock(block2);
            }
         }
      }
      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 specifiedload options. This constructor allows for the initialization of WebP images withcustomizable loading parameters, providing flexibility in image creation andmanipulation 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 informationabout the format in which the image is stored. Utilize this property to determinethe file format of the image, facilitating compatibility checks andformat-specific processing within your application.

public override FileFormat GetFileFormat()
    {
    }

Property Value

FileFormat

HasAlpha

Retrieve whether the image contains an alpha channel, indicating the presence oftransparency information. Utilize this property to determine whether the imageincludes transparency, enabling appropriate handling and processing ofalpha-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.

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;
      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);
         }
      }
   }

Options

Retrieve or modify the options associated with the specified property, enablingfine-tuned customization of behavior and settings. Utilize this property toseamlessly access and manipulate configurable parameters, facilitating versatilecontrol and optimization within your application’s functionality.

[JsonProperty]
    public WebPOptions Options
    {
        get;
    }

Property Value

WebPOptions

PageCount

Retrieve the total count of pages within the specified document, facilitatingefficient navigation and management of multi-page content. Incorporate thisfunctionality to enhance user experience, enabling seamless access tocomprehensive document structures.

public override int PageCount
   {
      get;
   }

Property Value

int

Pages

Access the WebP blocks within the image, allowing detailed examination ormanipulation of the underlying block structure. Utilize this property to analyzeor modify individual blocks within the WebP image data, facilitating advancedimage 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 andfacilitating advanced image manipulation. Integrate this method to dynamicallyenhance the structure and complexity of the WebP image data within yourapplication, 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.

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();
   createOptions.AnimLoopCount = 36 + 36 + 1;
   using (Aspose.Imaging.FileFormats.Webp.WebPImage webPImage = new Aspose.Imaging.FileFormats.Webp.WebPImage(100, 100, createOptions))
   {
      Aspose.Imaging.Brushes.SolidBrush brush1 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
      Aspose.Imaging.Brushes.SolidBrush brush2 = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Black);
      for (int angle = 10; angle <= 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);
      }
      for (int angle = 10; angle <= 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);
      }
      webPImage.Save(dir + "output.webp");
   }

AddPage(RasterImage)

Append a new page to the image, expanding its content and accommodating additionalvisual elements. Integrate this method to facilitate dynamic page managementwithin your application, enabling seamless creation and augmentation of multi-pagedocuments or images.

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 themodification of overall luminance levels. Incorporate this method into your imageprocessing workflow to enhance visibility and improve the visual quality of imageswithin your application.

public override void AdjustBrightness(int brightness)
   {
   }

Parameters

brightness int

Brightness value.

AdjustContrast(float)

Enhance the contrast of the Aspose.Imaging.Image, amplifying thedifferences between light and dark areas. Integrate this method into your imageprocessing workflow to improve visual clarity and overall image quality withinyour 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 achievedesired brightness and color balance. Incorporate this method into your imageprocessing workflow to enhance visual quality and improve the accuracy ofsubsequent 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 andcontrast. Integrate this method into your image processing pipeline to achieveprecise control over color rendering and enhance visual fidelity within yourapplication.

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 algorithmwith integral image thresholding. This method dynamically computes localthresholds based on the image’s neighborhood, enhancing adaptability to varyinglighting conditions and ensuring robust segmentation for subsequent processingtasks 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 pixelscentered 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, convertingit into a binary image where pixels are classified as foreground or backgroundbased on their intensity relative to the threshold. Integrate this method intoyour image processing workflow to facilitate segmentation and feature extractiontasks, enhancing the accuracy and efficiency of subsequent analysis within yourapplication.

public override void BinarizeFixed(byte threshold)
   {
   }

Parameters

threshold byte

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

BinarizeOtsu()

Perform binarization on the image using Otsu’s thresholding method, automaticallydetermining the optimal threshold value based on the image’s histogram. Integratethis method into your image processing workflow to achieve effective segmentationand feature extraction, enhancing the accuracy and reliability of image analysistasks within your application.

public override void BinarizeOtsu()
   {
   }

ClearBlocks()

Clear all existing WebP blocks from the image, facilitating a clean slate forsubsequent modifications or additions. Utilize this method to effectively resetthe block structure within the WebP image data, ensuring optimal management andorganization of image content within your application.

public void ClearBlocks()
   {
   }

Crop(Rectangle)

Crop the image using a specified rectangle region, removing unwanted portionswhile retaining the desired content. Integrate this method into your imageprocessing workflow to precisely extract and focus on specific areas of interestwithin 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, effectivelyselecting a region of interest within the image. Utilize this method todynamically extract desired portions of the image while adjusting its compositionand 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 visualquality. Integrate this method into your image processing workflow to achievesmoother transitions between colors and improve the overall appearance of theimage 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 imageprocessing filter to enhance or modify the selected region. Integrate this methodinto your image manipulation workflow to achieve targeted enhancements ortransformations within your application.

public override void
    Filter(Rectangle rectangle, FilterOptionsBase options)
Here is your re-formatted C# code according to standard C# conventions:
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.

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;
       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.FileFormatting.Webp.WebPImage)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.FileFormatting.Webp.WebPImage)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.FileFormatting.Webp.WebPImage)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.FileFormatting.Webp.WebPImage)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.FileFormatting.Webp.WebPImage)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());
   }

Grayscale()

Convert the image to its grayscale representation, transforming it into asingle-channel image where each pixel represents intensity or luminance. Integratethis method into your image processing pipeline to simplify analysis and enhancecompatibility with grayscale-based algorithms, facilitating various computervision and image analysis tasks within your application.

public override void Grayscale()
   {
   }

InsertBlock(int, IFrame)

Insert a new WebP block at the specified index within the image, enabling precisecontrol over the block sequence. Integrate this method to seamlessly incorporateadditional WebP blocks into the image data structure, facilitating advanced imageprocessing and optimization within your application.

public void InsertBlock(int index, IFrame block)
{
}

Parameters

index int

The zero-based element, at which block’ will beinserted.

block IFrame

The Webp block to add.

ReleaseManagedResources()

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

protected override void ReleaseManagedResources()
   {
       base.ReleaseManagedResources();
   }

RemoveBlock(IFrame)

Remove the specified WebP block from the image, facilitating efficient managementof image data structure. Utilize this method to streamline image processingworkflows 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 youwill 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 scaleimages 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.

string dir = "c:\\temp\\";
   using (Aspose.Imaging.FileFormats.Webp.WebPImage image = (Aspose.Imaging.FileFormats.Webp.WebPImage)Aspose.Imaging.Image.Load(dir + "sample.webp"))
   {
      image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
      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"))
   {
      image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
      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"))
   {
      image.Resize(image.Width * 2, image.Height * 2, Aspose.Imaging.ResizeType.BilinearResample);
      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"))
   {
      image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
      image.Save(dir + "downsample.bilinear.png", new Aspose.Imaging.ImageOptions.PngOptions());
   }

Resize(int, int, ImageResizeSettings)

Resize the image according to specified settings, enabling precise control overdimensions, aspect ratio, and scaling behavior. Integrate this method into yourimage processing workflow to achieve customized resizing operations tailored tothe specific requirements of your application.

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 ratiofor consistent resizing. Integrate this method into your image processing workflowto dynamically resize images with uniform proportions, ensuring optimal display orstorage 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 resizeimages with consistent proportions, ensuring optimal display or storage withinyour 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 proportionallyresizing it and applying specified background color parameters. Incorporate thismethod into your image processing workflow to achieve precise transformations withcustomizable background colors, ensuring optimal visual presentation within yourapplication.

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 changedaccording to rotated rectangle (corner points) projections in othercase that leaves dimensions untouched and onlyinternal image contents are rotated.

backgroundColor Color

Color of the background.

RotateFlip(RotateFlipType)

Apply rotation, flipping, or both operations exclusively to the active framewithin the image. Integrate this method into your image processing workflow toachieve precise manipulation of individual frames, enhancing flexibility andcontrol 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.

 English