Class GifImage

Class GifImage

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

The API for Graphical Interchange Format (GIF) image file provides developers with versatile tools for processing compressed raster images and animated GIFs. Offering features like XMP metadata handling, color palette settings, background and transparent color control, opacity settings, resize, crop, filter application, gamma corrections, contrast adjustment, grayscale transformation, and conversion to other formats. This API empowers seamless manipulation and enhancement of GIF images for a wide range of applications.

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

Inheritance

objectDisposableObjectDataStreamSupporterImageRasterImageRasterCachedImageRasterCachedMultipageImageGifImage

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

Export of part of animation from GIF image based on time interval.```csharp [C#]

                                                                         using (var image = Image.Load("Animation.gif"))
                                                                         {
                                                                             var options = new GifOptions
                                                                             {
                                                                                 FullFrame = true,
                                                                                 MultiPageOptions = new MultiPageOptions
                                                                                 {
                                                                                     Mode = MultiPageMode.TimeInterval,
                                                                                     TimeInterval = new TimeInterval(0, 400)
                                                                                 }
                                                                             };

                                                                             image.Save("PartOfAnimation.gif", options);
                                                                         }

This example shows how to create a GIF image and save it to a file.```csharp
[C#]

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

                                                                              // Create a GIF Frame block of 100x100 px.
                                                                              using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                              {
                                                                                  // Fill the entire block in red.
                                                                                  Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
                                                                                  Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                  gr.FillRectangle(brush, firstBlock.Bounds);

                                                                                  using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                                  {
                                                                                      gifImage.Save(dir + "output.gif");
                                                                                  }
                                                                              }

Create multipage GIF image using single page raster images.```csharp [C#]

                                                                  static void Main(string[] args)
                                                                  {
                                                                      // Load frames
                                                                      var frames = LoadFrames("Animation frames").ToArray();

                                                                      // Create GIF image using the first frame
                                                                      using (var image = new GifImage(new GifFrameBlock(frames[0])))
                                                                      {
                                                                          // Add frames to the GIF image using the AddPage method
                                                                          for (var index = 1; index < frames.Length; index++)
                                                                          {
                                                                              image.AddPage(frames[index]);
                                                                          }

                                                                          // Save GIF image
                                                                          image.Save("Multipage.gif");
                                                                      }
                                                                  }

                                                                  private static IEnumerable<rasterimage> LoadFrames(string directory)
                                                                  {
                                                                      foreach (var filePath in Directory.GetFiles(directory))
                                                                      {
                                                                          yield return (RasterImage)Image.Load(filePath);
                                                                      }
                                                                  }</rasterimage>

## Constructors

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage__ctor_Aspose_Imaging_FileFormats_Gif_Blocks_GifFrameBlock_Aspose_Imaging_IColorPalette_"></a> GifImage\(GifFrameBlock, IColorPalette\)

Initiate a new Aspose.Imaging.FileFormats.Gif.GifImage object with specified parameters for the 
first frame and global palette. Start managing GIF images swiftly, ensuring 
accurate representation with customizable settings for optimal results.

```csharp
public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette)

Parameters

firstFrame GifFrameBlock

The first frame to initialize gif image with.

globalPalette IColorPalette

The global palette to use. Note if both firstFrame and globalPalette are null then default global palette is used.

Examples

This example shows how to create a GIF image with a custom palette and save it to a file.```csharp [C#]

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

                                                                                                // Create a GIF Frame block of 100x100 px.
                                                                                                using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                                                {
                                                                                                    // Fill the entire block in red.
                                                                                                    Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
                                                                                                    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                                                    gr.FillRectangle(brush, firstBlock.Bounds);

                                                                                                    // Use 4-bit palette to reduce the image size. The quality can get worse.
                                                                                                    Aspose.Imaging.IColorPalette palette = Aspose.Imaging.ColorPaletteHelper.Create4Bit();

                                                                                                    using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock, palette))
                                                                                                    {
                                                                                                        gifImage.Save(dir + "output.gif");
                                                                                                    }
                                                                                                }

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

The <code class="paramref">firstFrame</code> cannot be null

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The <code class="paramref">firstFrame</code> already belongs to some other image. Check the Container property.

 [GifImageException](/imaging/aspose.imaging.coreexceptions.imageformats.gifimageexception)

The <code class="paramref">globalPalette</code> specified should contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage__ctor_Aspose_Imaging_FileFormats_Gif_Blocks_GifFrameBlock_"></a> GifImage\(GifFrameBlock\)

Crafting GIF images becomes effortless with the Aspose.Imaging.FileFormats.Gif.GifImage 
constructor. With just the firstFrame parameter, it enters in a world of dynamic 
visual communication.

```csharp
public GifImage(GifFrameBlock firstFrame)

Parameters

firstFrame GifFrameBlock

The first frame to initialize gif image with.

Examples

This example shows how to create a GIF image and save it to a file.```csharp [C#]

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

                                                                          // Create a GIF Frame block of 100x100 px.
                                                                          using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                          {
                                                                              // Fill the entire block in red.
                                                                              Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(firstBlock);
                                                                              Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
                                                                              gr.FillRectangle(brush, firstBlock.Bounds);

                                                                              using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                              {
                                                                                  gifImage.Save(dir + "output.gif");
                                                                              }
                                                                          }

The following example shows how to compose an animated GIF image from individual GIF blocks.```csharp
[C#]

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

                                                                                                       // Create a GIF image 100 x 100 px.
                                                                                                       // The first block is fully black by default.
                                                                                                       using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                                                       using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                                                       {
                                                                                                           // 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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

                                                                                                               Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
                                                                                                               gr.FillPie(brush1, block.Bounds, 0, angle);

                                                                                                               gifImage.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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

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

                                                                                                               gifImage.AddBlock(block);
                                                                                                           }

                                                                                                           gifImage.Save(dir + "animated_radar.gif");
                                                                                                       }

Exceptions

ArgumentNullException

The firstFrame cannot be null

ArgumentException

The firstFrame already belongs to some other image. Check the Container property.

GifImageException

The palette specified must contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.

GifImage(GifFrameBlock, IColorPalette, bool, byte, byte, byte, bool)

Get started effortlessly with the Aspose.Imaging.FileFormats.Gif.GifImage constructor. With this simple method, you can dive into creating animated GIFs with ease. Just supply the firstFrame, globalPalette, paletteColorResolution, aspectRatio, and other parameters, and you’re ready to bring your visuals to life.

public GifImage(GifFrameBlock firstFrame, IColorPalette globalPalette, bool isPaletteSorted, byte paletteColorResolution, byte paletteBackgroundColorIndex, byte aspectRatio, bool hasTrailer)

Parameters

firstFrame GifFrameBlock

The first frame to initialize gif image with.

globalPalette IColorPalette

The global palette to use. Note if both firstFrame and globalPalette are null then default global palette is used.

isPaletteSorted bool

if set to true the palette is sorted. Note the parameter is used when globalPalette is not null.

paletteColorResolution byte

The palette color resolution. Note the parameter is used when globalPalette is not null.

paletteBackgroundColorIndex byte

The palette background color index.

aspectRatio byte

The aspect ratio.

hasTrailer bool

if set to true the gif image has trailer otherwise no trailer written at the end of the stream.

Exceptions

ArgumentNullException

The firstFrame cannot be null

ArgumentException

The firstFrame already belongs to some other image. Check the Container property.

GifImageException

The globalPalette specified should contain entries count equal to power of 2. Minimal palette size is 2, maximal is 256.

Properties

ActiveFrame

Manage and manipulate frames with this property, enabling smooth navigation and modification of the active frame within the GIF image.

public GifFrameBlock ActiveFrame { get; set; }

Property Value

GifFrameBlock

Examples

The following example shows how to remove all blocks from a GIF image.```csharp [C#]

                                                                             using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                             using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                             {
                                                                                 if (gifImage.ActiveFrame != null)
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame is not set");
                                                                                 }

                                                                                 System.Console.WriteLine("Clear all the blocks");
                                                                                 gifImage.ClearBlocks();

                                                                                 if (gifImage.ActiveFrame != null)
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame is not set");
                                                                                 }
                                                                             }

                                                                             // The output looks like this:
                                                                             // Active frame size: { Width = 100, Height = 100}
                                                                             // Clear all the blocks
                                                                             // Active frame is not set

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_BackgroundColor"></a> BackgroundColor

Manage the background color of the GIF image with this property. You can set or 
retrieve the background color to ensure consistency and enhance visual appeal.

```csharp
public override Color BackgroundColor { get; set; }

Property Value

Color

BackgroundColorIndex

Control the background color index of the GIF image using this property. Set or retrieve the index to maintain consistency or achieve desired visual effects.

public byte BackgroundColorIndex { get; set; }

Property Value

byte

Blocks

Gain access to the GIF blocks seamlessly with this property, facilitating easy retrieval and manipulation of the image’s underlying data structures.

public IGifBlock[] Blocks { get; }

Property Value

IGifBlock[]

FileFormat

Retrieve the file format effortlessly with this property. It’s your go-to source for identifying the format of your files. Seamlessly integrated into your workflow, it provides vital information without any hassle.

public override FileFormat FileFormat { get; }

Property Value

FileFormat

HasBackgroundColor

This property determines whether the GIF image contains a background color. If true, it indicates that the image includes a background color.

public override bool HasBackgroundColor { get; }

Property Value

bool

HasTrailer

Manage the presence of a trailer in your GIF files with this property. Whether you need to check if a trailer exists or set its presence, this property simplifies the process. Keep your GIF files structured and compliant with this intuitive feature.

public bool HasTrailer { get; set; }

Property Value

bool

HasTransparentColor

Determine whether the active frame of the GIF image includes a transparent color. This property provides a convenient way to check for transparency within the image.

public override bool HasTransparentColor { get; set; }

Property Value

bool

ImageOpacity

Retrieve the opacity of the active frame within the image, offering insight into its transparency level. This property is particularly useful for understanding the degree of transparency or opaqueness of the active frame in the image.

public override float ImageOpacity { get; }

Property Value

float

IsInterlaced

Determines if the image is interlaced, impacting its display during loading. This property offers insight into the image’s rendering behavior, essential for optimizing loading strategies and enhancing overall viewing experience.

public bool IsInterlaced { get; }

Property Value

bool

IsPaletteSorted

Control the sorting of the palette in your GIF images using this property. Whether you need to check if the palette is sorted or set the sorting behavior, this property provides a straightforward way to manage the palette organization in your GIF files.

public bool IsPaletteSorted { get; set; }

Property Value

bool

LoopsCount

Retrieve the loop count effortlessly with this property. If your GIF image includes loop information, this property gives you quick access to the loop count, enabling you to seamlessly manage looping behavior in your GIF files.

public int LoopsCount { get; set; }

Property Value

int

PageCount

Retrieve the total number of pages contained within the image with this straightforward property. Ideal for quickly assessing the extent of the image content.

public override int PageCount { get; }

Property Value

int

Pages

Gain access to the pages within the image through this convenient property, allowing seamless navigation and manipulation of individual pages as needed.

public override Image[] Pages { get; }

Property Value

Image[]

PaletteColorResolutionBits

Manage the palette color resolution of your GIF images with this property. Adjust the number of bits used to represent colors in the palette, providing fine control over color depth and image quality.

public byte PaletteColorResolutionBits { get; set; }

Property Value

byte

PixelAspectRatio

Manage the pixel aspect ratio of the GIF image with this property. Set or retrieve the aspect ratio to ensure accurate rendering and maintain visual fidelity.

public byte PixelAspectRatio { get; set; }

Property Value

byte

TransparentColor

Retrieve the transparent color of the active frame in the GIF image. This property allows you to access the specific color that has been designated as transparent within the currently active frame.

public override Color TransparentColor { get; }

Property Value

Color

XmpData

Manage XMP metadata with this property. Whether you’re retrieving existing metadata or updating it with new information, this property streamlines the process. Keep your metadata organized and accessible, ensuring that your files contain the relevant information they need.

public override XmpPacketWrapper XmpData { get; set; }

Property Value

XmpPacketWrapper

Methods

AddBlock(IGifBlock)

Adding a new GIF block allows you to include additional data within the image. This method enables you to append custom blocks to the GIF image, which can contain various types of information.

public void AddBlock(IGifBlock block)

Parameters

block IGifBlock

The GIF block to add.

Examples

The following example shows how to compose an animated GIF image from individual GIF blocks.```csharp [C#]

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

                                                                                                   // Create a GIF image 100 x 100 px.
                                                                                                   // The first block is fully black by default.
                                                                                                   using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                                                   using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                                                   {
                                                                                                       // 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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

                                                                                                           Aspose.Imaging.Graphics gr = new Aspose.Imaging.Graphics(block);
                                                                                                           gr.FillPie(brush1, block.Bounds, 0, angle);

                                                                                                           gifImage.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.Gif.Blocks.GifFrameBlock block = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100);

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

                                                                                                           gifImage.AddBlock(block);
                                                                                                       }

                                                                                                       gifImage.Save(dir + "animated_radar.gif");
                                                                                                   }

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

Incorporate a new page seamlessly into the existing image, enhancing its content 
and expanding its scope. This method augment image collections with additional 
content, fostering creativity and flexibility in image management and composition.

```csharp
public void AddPage(RasterImage page)

Parameters

page RasterImage

The page to add.

Examples

Create multipage GIF image using single page raster images.```csharp [C#]

                                                                  static void Main(string[] args)
                                                                  {
                                                                      // Load frames
                                                                      var frames = LoadFrames("Animation frames").ToArray();

                                                                      // Create GIF image using the first frame
                                                                      using (var image = new GifImage(new GifFrameBlock(frames[0])))
                                                                      {
                                                                          // Add frames to the GIF image using the AddPage method
                                                                          for (var index = 1; index &lt; frames.Length; index++)
                                                                          {
                                                                              image.AddPage(frames[index]);
                                                                          }

                                                                          // Save GIF image
                                                                          image.Save("Multipage.gif");
                                                                      }
                                                                  }

                                                                  private static IEnumerable<rasterimage> LoadFrames(string directory)
                                                                  {
                                                                      foreach (var filePath in Directory.GetFiles(directory))
                                                                      {
                                                                          yield return (RasterImage)Image.Load(filePath);
                                                                      }
                                                                  }</rasterimage>

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

<code class="paramref">page</code> is null.

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_AdjustBrightness_System_Int32_"></a> AdjustBrightness\(int\)

Adjusts the brightness of the image according to the specified
<code class="paramref">brightness</code> parameter. This method modifies the brightness of 
the entire image uniformly, enhancing or reducing the overall luminance to achieve 
the desired effect.

```csharp
public override void AdjustBrightness(int brightness)

Parameters

brightness int

Brightness value.

Examples

The following example performs brightness correction of a GIF image.```csharp [C#]

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

                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                           {
                                                                               Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                               // Set the brightness value. The accepted values of brightness are in the range [-255, 255].
                                                                               gifImage.AdjustBrightness(50);
                                                                               gifImage.Save(dir + "sample.AdjustBrightness.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                           }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_AdjustContrast_System_Single_"></a> AdjustContrast\(float\)

Adjusts the contrast of the image, enhancing or reducing the difference in 
brightness between pixels. This method modifies the image's overall tonal range, 
making darker areas darker and brighter areas brighter to improve visual clarity 
and detail.

```csharp
public override void AdjustContrast(float contrast)

Parameters

contrast float

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

Examples

The following example performs contrast correction of a GIF image.```csharp [C#]

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

                                                                         using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                         {
                                                                             Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                             // Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
                                                                             gifImage.AdjustContrast(50f);
                                                                             gifImage.Save(dir + "sample.AdjustContrast.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                         }

#### Exceptions

 [ImageException](/imaging/aspose.imaging.coreexceptions.imageexception)

Can't change contrast. Frame index: " + frameIndex

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_AdjustGamma_System_Single_"></a> AdjustGamma\(float\)

Enhance image quality by applying gamma correction. This method adjusts the color 
gamma of the image to achieve optimal visual clarity. It modifies the gamma value 
of each pixel, resulting in improved color rendition and overall image appearance.

```csharp
public override void AdjustGamma(float gamma)

Parameters

gamma float

Gamma for red, green and blue channels coefficient

Examples

The following example performs gamma-correction of a GIF image.```csharp [C#]

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

                                                                      using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                      {
                                                                          Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                          // Set gamma coefficient for red, green and blue channels.
                                                                          gifImage.AdjustGamma(2.5f);
                                                                          gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                      }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_AdjustGamma_System_Single_System_Single_System_Single_"></a> AdjustGamma\(float, float, float\)

Gamma-correction of an image applies a nonlinear adjustment to the pixel values, 
enhancing or reducing brightness based on the specified coefficients for the red, 
green, and blue channels. This method helps to fine-tune the color balance and 
luminance of the image, improving its overall appearance and visual quality.

```csharp
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

Examples

The following example performs gamma-correction of a GIF image applying different coefficients for color components.```csharp [C#]

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

                                                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                           {
                                                                                                                               Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                               // Set individual gamma coefficients for red, green and blue channels.
                                                                                                                               gifImage.AdjustGamma(1.5f, 2.5f, 3.5f);
                                                                                                                               gifImage.Save(dir + "sample.AdjustGamma.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                           }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_BinarizeBradley_System_Double_"></a> BinarizeBradley\(double\)

Binarization of an image using Bradley's adaptive thresholding algorithm with 
integral image thresholding is a method for converting a grayscale image into a 
binary image. This algorithm calculates a local threshold for each pixel based on 
the average intensity of the surrounding pixels within a specified window. By 
adaptively adjusting the threshold based on local pixel intensities, Bradley's 
method is effective at handling variations in lighting and contrast across the image.

```csharp
public override void BinarizeBradley(double brightnessDifference)

Parameters

brightnessDifference double

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

BinarizeFixed(byte)

Binarization of an image with a predefined threshold converts a grayscale or color image into a binary image, where each pixel is classified as either black or white based on whether its intensity value exceeds a specified threshold.

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.

Examples

The following example binarizes a GIF image with the predefined threshold. Binarized images contain only 2 colors - black and white.```csharp [C#]

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

                                                                                                                                           using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                           {
                                                                                                                                               Aspose.Imaging.FileFormats.Gif.GifImage djvuImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                                               // Binarize the image with a threshold value of 127.
                                                                                                                                               // If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
                                                                                                                                               djvuImage.BinarizeFixed(127);
                                                                                                                                               djvuImage.Save(dir + "sample.BinarizeFixed.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                           }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_BinarizeOtsu"></a> BinarizeOtsu\(\)

Binarization of an image with Otsu thresholding is a method used to automatically 
determine the optimal threshold value for converting a grayscale image into a 
binary image. The Otsu thresholding algorithm calculates the threshold that 
minimizes the intra-class variance of the pixel intensities in the two resulting 
classes (foreground and background). This technique is particularly useful when 
the optimal threshold value is unknown and needs to be determined adaptively based 
on the image's histogram.

```csharp
public override void BinarizeOtsu()

Examples

The following example binarizes a GIF image with Otsu thresholding. Binarized images contain only 2 colors - black and white.```csharp [C#]

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

                                                                                                                                    using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                    {
                                                                                                                                        Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                                        // Binarize the image with Otsu thresholding.
                                                                                                                                        gifImage.BinarizeOtsu();
                                                                                                                                        gifImage.Save(dir + "sample.BinarizeOtsu.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                    }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_ClearBlocks"></a> ClearBlocks\(\)

Clearing all the GIF blocks removes any existing data stored within the image. 
This operation effectively resets the image to an empty state, removing any 
previously added blocks. Use this method when you need to start fresh with a clean 
slate for creating or modifying a GIF image.

```csharp
public void ClearBlocks()

Examples

The following example shows how to remove all blocks from a GIF image.```csharp [C#]

                                                                             using (Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock firstBlock = new Aspose.Imaging.FileFormats.Gif.Blocks.GifFrameBlock(100, 100))
                                                                             using (Aspose.Imaging.FileFormats.Gif.GifImage gifImage = new Aspose.Imaging.FileFormats.Gif.GifImage(firstBlock))
                                                                             {
                                                                                 if (gifImage.ActiveFrame != null)
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame is not set");
                                                                                 }

                                                                                 System.Console.WriteLine("Clear all the blocks");
                                                                                 gifImage.ClearBlocks();

                                                                                 if (gifImage.ActiveFrame != null)
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame size: {0}", gifImage.ActiveFrame.Size);
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     System.Console.WriteLine("Active frame is not set");
                                                                                 }
                                                                             }

                                                                             // The output looks like this:
                                                                             // Active frame size: { Width = 100, Height = 100}
                                                                             // Clear all the blocks
                                                                             // Active frame is not set

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_Crop_Aspose_Imaging_Rectangle_"></a> Crop\(Rectangle\)

Crop the image using a specified rectangle area. This operation removes the outer 
portion of the image, leaving only the selected region defined by the rectangle.

```csharp
public override void Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle.

Examples

The following example crops a GIF image. The cropping area is be specified via Aspose.Imaging.Rectangle.```csharp [C#]

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

                                                                                                               using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                               {
                                                                                                                   Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                   // Crop the image. The cropping area is the rectangular central area of the image.
                                                                                                                   Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(gifImage.Width / 4, gifImage.Height / 4, gifImage.Width / 2, gifImage.Height / 2);
                                                                                                                   gifImage.Crop(area);

                                                                                                                   // Save the cropped image to PNG
                                                                                                                   gifImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                               }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_Dither_Aspose_Imaging_DitheringMethod_System_Int32_Aspose_Imaging_IColorPalette_"></a> Dither\(DitheringMethod, int, IColorPalette\)

Apply dithering to the current image. This process enhances image quality by 
reducing color banding and improving color transitions, resulting in a smoother 
appearance.

```csharp
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.

Examples

The following example loads a GIF image and performs threshold and floyd dithering using different palette depth.```csharp [C#]

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

                                                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                        {
                                                                                                                            Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                            // Perform threshold dithering using 4-bit color palette which contains 16 colors.
                                                                                                                            // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                            // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                            gifImage.Dither(Aspose.Imaging.DitheringMethod.ThresholdDithering, 4, null);

                                                                                                                            gifImage.Save(dir + "sample.ThresholdDithering4.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                        }

                                                                                                                        using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                        {
                                                                                                                            Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                            // Perform floyd dithering using 1-bit color palette which contains only 2 colors - black and white.
                                                                                                                            // The more bits specified the higher quality and the bigger size of the output image.
                                                                                                                            // Note that only 1-bit, 4-bit and 8-bit palettes are supported at the moment.
                                                                                                                            gifImage.Dither(Aspose.Imaging.DitheringMethod.FloydSteinbergDithering, 1, null);

                                                                                                                            gifImage.Save(dir + "sample.FloydSteinbergDithering1.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                        }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_Filter_Aspose_Imaging_Rectangle_Aspose_Imaging_ImageFilters_FilterOptions_FilterOptionsBase_"></a> Filter\(Rectangle, FilterOptionsBase\)

Apply a specific filter to the designated area of the image, enhancing its visual 
quality or altering its appearance as desired. This method selectively processes 
pixels within the defined rectangle, allowing for targeted adjustments to be made 
while preserving the integrity of the surrounding image data.

```csharp
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 GIF image.```csharp [C#]

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

                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                             {
                                                                                 Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

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

                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                             {
                                                                                 Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

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

                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                             {
                                                                                 Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                 // Apply a Gaussian blur filter with a radius of 5 and a sigma value of 4.0 to the entire image.
                                                                                 gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 4.0));
                                                                                 gifImage.Save(dir + "sample.GaussianBlurFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                             }

                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                             {
                                                                                 Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                 // Apply a Gauss-Wiener filter with a radius of 5 and a smooth value of 4.0 to the entire image.
                                                                                 gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussWienerFilterOptions(5, 4.0));
                                                                                 gifImage.Save(dir + "sample.GaussWienerFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                             }

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

                                                                             using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                             {
                                                                                 Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                 // Apply a sharpen filter with a kernel size of 5 and a sigma value of 4.0 to the entire image.
                                                                                 gifImage.Filter(gifImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.SharpenFilterOptions(5, 4.0));
                                                                                 gifImage.Save(dir + "sample.SharpenFilter.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                             }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_GetOriginalOptions"></a> GetOriginalOptions\(\)

Retrieve the original file settings-based options, crucial for maintaining fidelity 
and consistency in image processing and manipulation. This method allows seamless 
integration of file-specific parameters into subsequent operations, ensuring 
accurate rendition and adherence to the image's inherent characteristics.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
Aspose.Imaging.DataStreamSupporter.Save(System.String) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Aspose.Imaging.Image.Save(System.String,Aspose.Imaging.ImageOptionsBase) method as the second parameter.

```csharp
public override ImageOptionsBase GetOriginalOptions()

Returns

ImageOptionsBase

The options based on the original file settings.

Grayscale()

The transformation of an image to its grayscale representation converts the color image into a grayscale version by removing color information while preserving luminance. This process simplifies the image to shades of gray, making it suitable for various applications such as printing, document processing, and grayscale analysis.

public override void Grayscale()

Examples

The following example transforms a colored GIF image to its grayscale representation. Grayscale images are composed exclusively of shades of gray and carry only intensity information.```csharp [C#]

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

                                                                                                                                                                                              using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                                                                              {
                                                                                                                                                                                                  Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                                                                                                                                  gifImage.Grayscale();
                                                                                                                                                                                                  gifImage.Save(dir + "sample.Grayscale.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                                                                              }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_InsertBlock_System_Int32_Aspose_Imaging_FileFormats_Gif_IGifBlock_"></a> InsertBlock\(int, IGifBlock\)

Inserting a new GIF block allows you to add custom data at a specific position 
within the image. This method enables you to place custom blocks at a desired 
location in the GIF image, providing flexibility in organizing and structuring the 
image data.

```csharp
public void InsertBlock(int index, IGifBlock block)

Parameters

index int

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

block IGifBlock

The GIF block to add.

OnPaletteChanged(IColorPalette, IColorPalette)

Called when palette is changed.

protected override void OnPaletteChanged(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

The old palette.

newPalette IColorPalette

The new palette.

OnPaletteChanging(IColorPalette, IColorPalette)

Called when palette is changing.

protected override void OnPaletteChanging(IColorPalette oldPalette, IColorPalette newPalette)

Parameters

oldPalette IColorPalette

The old palette.

newPalette IColorPalette

The new palette.

OrderBlocks()

Ordering the GIF blocks according to the GIF specification ensures proper GIF layout and compliance with the standard. This process involves arranging the blocks in the correct sequence as defined by the specification. Additionally, it may involve removing certain Aspose.Imaging.FileFormats.Gif.Blocks.GifGraphicsControlBlock instances that are not necessary for the final layout. By adhering to the GIF specification, the resulting image will be correctly structured and compatible with GIF viewing applications.

public void OrderBlocks()

RemoveBlock(IGifBlock)

Removing a GIF block removes specific data from the image, offering the ability to clean up or modify the image structure. This method enables you to remove unwanted or unnecessary blocks, optimizing the GIF image for efficient storage. Use this functionality to eliminate outdated information from the image while preserving its integrity and quality.

public void RemoveBlock(IGifBlock block)

Parameters

block IGifBlock

The block to remove.

Remarks

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

Resize(int, int, ResizeType)

Resizes this Aspose.Imaging.Image instance.

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 GIF image and resizes it using various resizing methods.```csharp [C#]

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

                                                                                    using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                    {
                                                                                        // Scale up by 2 times using Nearest Neighbour resampling.
                                                                                        image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                        image.Save(dir + "upsample.nearestneighbour.gif");
                                                                                    }

                                                                                    using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                    {
                                                                                        // Scale down by 2 times using Nearest Neighbour resampling.
                                                                                        image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
                                                                                        image.Save(dir + "downsample.nearestneighbour.gif");
                                                                                    }

                                                                                    using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                    {
                                                                                        // Scale up by 2 times using Bilinear resampling.
                                                                                        image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                        image.Save(dir + "upsample.bilinear.gif");
                                                                                    }

                                                                                    using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                    {
                                                                                        // Scale down by 2 times using Bilinear resampling.
                                                                                        image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
                                                                                        image.Save(dir + "downsample.bilinear.gif");
                                                                                    }

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

Resizes this Aspose.Imaging.Image instance.

```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 settings.

Examples

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

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

                                                                                     Aspose.Imaging.ImageResizeSettings resizeSettings = new Aspose.Imaging.ImageResizeSettings();

                                                                                     // The adaptive algorithm based on weighted and blended rational function and lanczos3 interpolation.
                                                                                     resizeSettings.Mode = Aspose.Imaging.ResizeType.AdaptiveResample;

                                                                                     // The small rectangular filter
                                                                                     resizeSettings.FilterType = Aspose.Imaging.ImageFilterType.SmallRectangular;

                                                                                     // The number of colors in the palette.
                                                                                     resizeSettings.EntriesCount = 256;

                                                                                     // The color quantization is not used
                                                                                     resizeSettings.ColorQuantizationMethod = ColorQuantizationMethod.None;

                                                                                     // The euclidian method
                                                                                     resizeSettings.ColorCompareMethod = ColorCompareMethod.Euclidian;

                                                                                     using (Aspose.Imaging.Image image = (Aspose.Imaging.Image)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                     {
                                                                                         Aspose.Imaging.FileFormats.Gif.GifImage gifImage = (Aspose.Imaging.FileFormats.Gif.GifImage)image;

                                                                                         // Scale down by 2 times using adaptive resampling.
                                                                                         gifImage.Resize(image.Width / 2, image.Height / 2, resizeSettings);

                                                                                         // Save to PNG
                                                                                         gifImage.Save(dir + "downsample.adaptive.png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                     }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_ResizeFullFrame_System_Int32_System_Int32_Aspose_Imaging_ResizeType_"></a> ResizeFullFrame\(int, int, ResizeType\)

Resizing of the image while taking into account the full frames for each page in a 
GIF, thus preventing potential artifacts from appearing. This method is essential 
to maintain the integrity and quality of the image, especially when dealing with 
animated GIFs or sequences of frames.

```csharp
public void ResizeFullFrame(int newWidth, int newHeight, ResizeType resizeType)

Parameters

newWidth int

The new width.

newHeight int

The new height.

resizeType ResizeType

The resize type.

ResizeProportional(int, int, ResizeType)

Proportional resizing maintains the aspect ratio of the image while adjusting its size, ensuring that the image does not appear stretched or distorted. This method resizes the image proportionally, scaling both the width and height by the same factor. The proportional resize will resize each frame according to the ratio of newWidth/width and newHeight/height.

public void ResizeProportional(int newWidth, int newHeight, ResizeType resizeType)

Parameters

newWidth int

The new width.

newHeight int

The new height.

resizeType ResizeType

The resize type.

Rotate(float, bool, Color)

This method rotates the image around its center point. By specifying the rotation angle, you can rotate the image clockwise or counterclockwise to achieve the desired orientation. This rotation helps adjust the image’s presentation or alignment without distorting its content.

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)

Perform rotation, flipping, or both on the active frame exclusively. This operation applies transformations solely to the currently active frame of the image, preserving the integrity of other frames in the sequence.

public override void RotateFlip(RotateFlipType rotateFlipType)

Parameters

rotateFlipType RotateFlipType

The rotate flip type.

Examples

This example loads a GIF image, rotates it by 90 degrees clockwise and optionally flips the image horizontally and(or) vertically.```csharp [C#]

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

                                                                                                                                         Aspose.Imaging.RotateFlipType[] rotateFlipTypes = new Aspose.Imaging.RotateFlipType[]
                                                                                                                                         {
                                                                                                                                             Aspose.Imaging.RotateFlipType.Rotate90FlipNone,
                                                                                                                                             Aspose.Imaging.RotateFlipType.Rotate90FlipX,
                                                                                                                                             Aspose.Imaging.RotateFlipType.Rotate90FlipXY,
                                                                                                                                             Aspose.Imaging.RotateFlipType.Rotate90FlipY,
                                                                                                                                         };

                                                                                                                                         foreach (Aspose.Imaging.RotateFlipType rotateFlipType in rotateFlipTypes)
                                                                                                                                         {
                                                                                                                                             // Rotate, flip and save to the output file.
                                                                                                                                             using (Aspose.Imaging.FileFormats.Gif.GifImage image = (Aspose.Imaging.FileFormats.Gif.GifImage)Aspose.Imaging.Image.Load(dir + "sample.gif"))
                                                                                                                                             {
                                                                                                                                                 image.RotateFlip(rotateFlipType);
                                                                                                                                                 image.Save(dir + "sample." + rotateFlipType + ".png", new Aspose.Imaging.ImageOptions.PngOptions());
                                                                                                                                             }
                                                                                                                                         }

### <a id="Aspose_Imaging_FileFormats_Gif_GifImage_SaveData_System_IO_Stream_"></a> SaveData\(Stream\)

Saves the data.

```csharp
protected override void SaveData(Stream stream)

Parameters

stream Stream

The stream to save data to.

SetFrameTime(ushort)

Adjusts the duration of each frame in milliseconds, ensuring consistent timing throughout the image sequence. This method uniformly sets the display time for every frame, allowing for precise control over animation speed. Changing this value will reset delay for all frames.

public void SetFrameTime(ushort time)

Parameters

time ushort

The time of frame duration in milliseconds.

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.