ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / GIFFormat Class
Members Example

In This Topic
    GIFFormat Class
    In This Topic
    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
    ExportGIF_Layout
    //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);
          }
        });
      }
    }
    ExportGIF_MapFrame
    //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);
          }
        });
      }
    }
    ExportGIF_ActiveMap
    //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 mapv = 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())
          {
            mapv.Export(GIF);
          }
        });
      }
    }
    GIF_Constructor
    GIFFormat GIF = new GIFFormat();
    Inheritance Hierarchy

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

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also