# Work with Exif Metadata

Use DsImaging to extract and modify the Exif metadata from various image formats, such as JPEG, PNG, or TIFF files.

## Content

The DsImaging library supports the extraction and modification of Exif metadata from various image formats, such as JPEG, PNG or TIFF files. With DsImaging, a developer can extract all Exif metadata from the images as mentioned in the Exif specifications sheet, such as the shutter speed, time it was taken, focal length, light value, use of flash, title, date, creator, copyright, description location (GPS data) etc..
DsImaging provides all the Exif metadata of an image in the [ExifProfile](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.html) class which is available in [GrapeCity.Documents.Imaging.Exif](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.html) namespace. The library also provides [ExifProfile](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.html) property of the [GcBitmap](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.GcBitmap.html) class through which Exif metadata of the images can be accessed. The ExifProfile class mainly includes two methods, namely [GetTags](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.GetTags.html) and [GetValues](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.GetValues.html). The **GetTags** method returns an array of all known tags in the profile. On the other hand, the **GetValues** method returns a list of all known tags in the profile along with their corresponding values. These tags are represented by the [ExifTag](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifTag.html) enumeration and values are represented by the [ExifValue](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifValue.html) class. These values can also be accessed through special properties such as [Orientation](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.Orientation.html), [ResolutionUnit](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.ResolutionUnit.html), [LensModel](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.LensModel.html), etc. provided by the ExifProfile class. The class also caters the unknown tags using the [UnknownTags](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.UnknownTags.html) property which gets a list of values for the unknown tags. Moreover, if required, you can save the Exif metadata to a stream or a byte array using [SaveToStream](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.SaveToStream.html) and [ToByteArray](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.ToByteArray.html) methods of the **ExifProfile** class respectively and also load the Exif metadata from a stream or a byte array using [Load](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.Exif.ExifProfile.Load.html) method of the ExifProfile class.
![Image of fire breakout with Exif metadata mentioned by its side](https://cdn.mescius.io/document-site-files/images/a5680f0e-2d32-45dc-8048-d3ef11d0dae7/images/exifmetadata.png)
To extract and modify the EXIF metadata of an image:

1. Initialize the GcBitmap class.
2. Create an instance of **ExifProfile** class and get the instance with the Exif metadata of the image using the **ExifProfile** property.
3. Get all the known tags values using the **GetValues** method of ExifProfile class.
4. Access all the known tags of the profile using the **GetTags** method of ExifProfile class.
5. Initialize an instance of the [TextLayout](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Text.TextLayout.html) class and add all the known tags and values to the **TextLayout** object.
6. Render the EXIF metadata of the image along with the image using the [DrawTextLayout](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.DrawTextLayout.html) and [DrawImage](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.DrawImage.html) methods respectively.

    ```csharp
    //Image path
        var imgPath = Path.Combine("Resources", "Images", "fire.jpg");
    
        //Initialize GcBitmap and create bitmap graphics
        GcBitmap origbmp = new GcBitmap(imgPath);
    
        //Get all the known tags values
        ExifProfile ep = origbmp.ExifProfile;
        List<KeyValuePair<ExifTag, ExifValue>> knownTagsValues = ep.GetValues();
    
        //Create TextLayout used to show EXIF metadata of the image
        TextLayout tl = new TextLayout();
        if (knownTagsValues.Count > 0)
        {
            tl.Append("Known tags(" + knownTagsValues.Count.ToString() + "): \r\n");
            tl.AppendLine();
    
            //Add known tags values to the textlayout
            foreach (KeyValuePair<ExifTag, ExifValue> tag in knownTagsValues)
                tl.AppendLine(tag.Key + "\t" + tag.Value);
        }
        else
            tl.Append("No known tags");
    
        //Render the created TextLayout and the original image on the output image
        GcBitmap targetBmp = new GcBitmap(700, 850, true);
        GcBitmapGraphics g = targetBmp.CreateGraphics(Color.White);
        using (var img = Image.FromFile(imgPath))
            g.DrawImage(img, new RectangleF(20, 30, 200, 200), null, 
                ImageAlign.ScaleImage);
        g.DrawTextLayout(tl, new PointF(260, 30));
    
        //Save the image
        targetBmp.SaveAsJpeg("ExifMetadata.jpg");
    }
    ```

For more information about working with EXIF metadata using DsImaging, see [DsImaging sample browser](https://developer.mescius.com/documents-api-imaging/demos/basics/exif/show-exif/code-cs).