ArcGIS Pro 2.9 API Reference Guide
GIFFormat Class
Members  Example 

ArcGIS.Desktop.Mapping Namespace : GIFFormat Class
Represents an Graphic Interchange Format (GIF) object that can be used to export a MapView, MapFrame, or a Layout.
Syntax
public class GIFFormat : ExportFormat 
Public Class GIFFormat 
   Inherits ExportFormat
Remarks
GIF files are a legacy raster format for use on the web. GIFs cannot contain more than 256 colors (8-bits per pixel), which along with optional lossless compression, makes them smaller than other file formats.
Example
The following examples demonstrate how to export a Layout, a MapFrame, and a MapView to GIF format.
//This example demonstrates how to export a layout to GIF.

//Added references
using ArcGIS.Desktop.Core;                         //Project
using ArcGIS.Desktop.Layouts;                      //Layout classes
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //Export formats

public class ExportLayoutToGIFExample
{
  public static Task ExportLayoutToGIFAsync(string LayoutName, string Path)
  {
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));
    if (layoutItem == null)
      return Task.FromResult<Layout>(null);

    //Create GIF format with appropriate settings
    GIFFormat GIF = new GIFFormat();
    GIF.Resolution = 300;
    GIF.OutputFileName = Path;

    return QueuedTask.Run(() =>
    {
            //Export Layout
            Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
            if (GIF.ValidateOutputFilePath())
      {
        lyt.Export(GIF);
      }
    });
  }
}
//This example demonstrates how to export an individual map frame on a layout to GIF.

//Added references
using ArcGIS.Desktop.Core;                         //Project
using ArcGIS.Desktop.Layouts;                      //Layout classes
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //Export formats

public class ExportMapFrameToGIFExample
{
  public static Task ExportMapFrameToGIFAsync(string LayoutName, string MFName, string Path)
  {
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName));
    if (layoutItem == null)
      return Task.FromResult<Layout>(null);

    //Create GIF format with appropriate settings
    GIFFormat GIF = new GIFFormat();
    GIF.HasWorldFile = true;
    GIF.Resolution = 300;
    GIF.OutputFileName = Path;

    return QueuedTask.Run(() =>
    {
            //Export MapFrame
            Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
            MapFrame mf = lyt.FindElement(MFName) as MapFrame;
      GIF.OutputFileName = Path;
      if (GIF.ValidateOutputFilePath())
      {
        mf.Export(GIF);
      }
    });
  }
}
//This example demonstrates how to export the active mapview to GIF.

//Added references
using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
using ArcGIS.Desktop.Mapping;                      //MapView and Export formats

public class ExportActiveMapToGIFExample
{
  public static Task ExportActiveMapToGIFAsync(string Path)
  {
    return QueuedTask.Run(() =>
    {
            //Reference the active map view
            MapView map = MapView.Active;

            //Create GIF format with appropriate settings
            GIFFormat GIF = new GIFFormat();
      GIF.Resolution = 300;
      GIF.Height = 500;
      GIF.Width = 800;
      GIF.HasWorldFile = true;
      GIF.OutputFileName = Path;

            //Export active map view
            if (GIF.ValidateOutputFilePath())
      {
        map.Export(GIF);
      }
    });
  }
}
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Mapping.ExportFormat
      ArcGIS.Desktop.Mapping.GIFFormat

Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

GIFFormat Members
ArcGIS.Desktop.Mapping Namespace