Save metadata?

Hello,
After loading any of supported images, is it possible to export all of the Exif, Xmp, Iptc and Gps fields of the loaded image to disk as file (ie xml)?
If so, any sample on that? :slight_smile:
Thanks.

Hi, @australian.dev.nerds
In the following example, there is one of many options to get Exif, JFif, GPS values from Jpeg.
You need to replace Console.WriteLine by a code that saves values in XML/JSON or other formats.

using (JpegImage image = (JpegImage)Image.Load("any-jpeg-image.jpg"))
{
    JpegExifData exifData = image.ExifData;
    if (exifData != null)
    {
        Type type = exifData.GetType();
        PropertyInfo[] properties = type.GetProperties();
        foreach (PropertyInfo property in properties)
        {
            var value = property.GetValue(exifData, null);
            if (value != null)
            {
                if (property.PropertyType.IsArray)
                {
                    Console.WriteLine(property.Name + ":");
                    foreach (var item in (Array)value)
                    {
                        Console.WriteLine("  {0}", item);
                    }
                }
                else
                    Console.WriteLine(property.Name + ":" + value);
            }
        }
    }
    JFIFData jfifData = image.Jfif;
    if (jfifData != null)
    {
        Type type = jfifData.GetType();
        PropertyInfo[] properties = type.GetProperties();
        foreach (PropertyInfo property in properties)
        {
            var value = property.GetValue(exifData, null);
            if (value != null)
            {
                if (property.PropertyType.IsArray)
                {
                    Console.WriteLine(property.Name + ":");
                    foreach (var item in (Array)value)
                    {
                        Console.WriteLine("  {0}", item);
                    }
                }
                else
                    Console.WriteLine(property.Name + ":" + value);
            }
        }
    }
}