/// <exception cref="Com.Adobe.Xmp.XMPException"/>
 private void ProcessXmpDateTag(XMPMeta meta, XmpDirectory directory, string schemaNS, string propName, int tagType)
 {
     Sharpen.Calendar cal = meta.GetPropertyCalendar(schemaNS, propName);
     if (cal != null)
     {
         directory.SetDate(tagType, cal.GetTime());
     }
 }
 /// <exception cref="Com.Adobe.Xmp.XMPException"/>
 private static void ProcessXmpTags(XmpDirectory directory, XMPMeta xmpMeta)
 {
     // store the XMPMeta object on the directory in case others wish to use it
     directory.SetXMPMeta(xmpMeta);
     // read all the tags and send them to the directory
     // I've added some popular tags, feel free to add more tags
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLensInfo, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLens, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagCameraSerialNumber, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFirmware, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagMake, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagModel, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagExposureTime, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagExposureProgram, FmtInt);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagApertureValue, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFNumber, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFocalLength, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagShutterSpeed, FmtRational);
     ProcessXmpDateTag(xmpMeta, directory, XmpDirectory.TagDatetimeOriginal);
     ProcessXmpDateTag(xmpMeta, directory, XmpDirectory.TagDatetimeDigitized);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagRating, FmtDouble);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLabel, FmtString);
     // this requires further research
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:title", XmpDirectory.TAG_TITLE, FMT_STRING);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagSubject, FmtStringArray);
     // processXmpDateTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:date", XmpDirectory.TAG_DATE);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:type", XmpDirectory.TAG_TYPE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:description", XmpDirectory.TAG_DESCRIPTION, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:relation", XmpDirectory.TAG_RELATION, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:coverage", XmpDirectory.TAG_COVERAGE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:creator", XmpDirectory.TAG_CREATOR, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:publisher", XmpDirectory.TAG_PUBLISHER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:contributor", XmpDirectory.TAG_CONTRIBUTOR, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:rights", XmpDirectory.TAG_RIGHTS, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:format", XmpDirectory.TAG_FORMAT, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:identifier", XmpDirectory.TAG_IDENTIFIER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:language", XmpDirectory.TAG_LANGUAGE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:audience", XmpDirectory.TAG_AUDIENCE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:provenance", XmpDirectory.TAG_PROVENANCE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:rightsHolder", XmpDirectory.TAG_RIGHTS_HOLDER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:instructionalMethod", XmpDirectory.TAG_INSTRUCTIONAL_METHOD,
     // FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualMethod", XmpDirectory.TAG_ACCRUAL_METHOD, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualPeriodicity", XmpDirectory.TAG_ACCRUAL_PERIODICITY,
     // FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualPolicy", XmpDirectory.TAG_ACCRUAL_POLICY, FMT_STRING);
     for (XMPIterator iterator = xmpMeta.Iterator(); iterator.HasNext();)
     {
         XMPPropertyInfo propInfo = (XMPPropertyInfo)iterator.Next();
         string          path     = propInfo.GetPath();
         string          value    = propInfo.GetValue();
         if (path != null && value != null)
         {
             directory.AddProperty(path, value);
         }
     }
 }
Beispiel #3
0
        /// <exception cref="System.IO.IOException"/>
        public static XmpDirectory ProcessApp1Bytes(string filePath)
        {
            Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
            new XmpReader().Extract(FileUtil.ReadBytes(filePath), metadata, JpegSegmentType.App1);
            XmpDirectory directory = metadata.GetDirectory <XmpDirectory>();

            NUnit.Framework.Assert.IsNotNull(directory);
            return(directory);
        }
        /// <exception cref="Com.Adobe.Xmp.XMPException"/>
        private static void ProcessXmpDateTag([NotNull] XMPMeta meta, [NotNull] XmpDirectory directory, int tagType)
        {
            string schemaNS = XmpDirectory._tagSchemaMap.Get(tagType);
            string propName = XmpDirectory._tagPropNameMap.Get(tagType);

            Sharpen.Calendar cal = meta.GetPropertyCalendar(schemaNS, propName);
            if (cal != null)
            {
                directory.SetDate(tagType, cal.GetTime());
            }
        }
 public virtual void SetUp()
 {
     Com.Drew.Metadata.Metadata metadata = new Com.Drew.Metadata.Metadata();
     IList<sbyte[]> jpegSegments = new AList<sbyte[]>();
     jpegSegments.Add(FileUtil.ReadBytes("Tests/Data/withXmpAndIptc.jpg.app1.1"));
     new XmpReader().ReadJpegSegments(jpegSegments.AsIterable(), metadata, JpegSegmentType.App1);
     ICollection<XmpDirectory> xmpDirectories = metadata.GetDirectoriesOfType<XmpDirectory>();
     NUnit.Framework.Assert.IsNotNull(xmpDirectories);
     Sharpen.Tests.AreEqual(1, xmpDirectories.Count);
     _directory = xmpDirectories.Iterator().Next();
     Sharpen.Tests.IsFalse(_directory.HasErrors());
 }
        /// <summary>
        /// Performs the XMP data extraction, adding found values to the specified instance of
        /// <see cref="Com.Drew.Metadata.Metadata"/>
        /// .
        /// <p/>
        /// The extraction is done with Adobe's XMPCore library.
        /// </summary>
        public virtual void Extract(string xmpString, Com.Drew.Metadata.Metadata metadata)
        {
            XmpDirectory directory = metadata.GetOrCreateDirectory <XmpDirectory>();

            try
            {
                XMPMeta xmpMeta = XMPMetaFactory.ParseFromString(xmpString);
                ProcessXmpTags(directory, xmpMeta);
            }
            catch (XMPException e)
            {
                directory.AddError("Error processing XMP data: " + e.Message);
            }
        }
        public virtual void SetUp()
        {
            Com.Drew.Metadata.Metadata metadata     = new Com.Drew.Metadata.Metadata();
            IList <sbyte[]>            jpegSegments = new AList <sbyte[]>();

            jpegSegments.Add(FileUtil.ReadBytes("Tests/Data/withXmpAndIptc.jpg.app1.1"));
            new XmpReader().ReadJpegSegments(jpegSegments.AsIterable(), metadata, JpegSegmentType.App1);
            ICollection <XmpDirectory> xmpDirectories = metadata.GetDirectoriesOfType <XmpDirectory>();

            NUnit.Framework.Assert.IsNotNull(xmpDirectories);
            Sharpen.Tests.AreEqual(1, xmpDirectories.Count);
            _directory = xmpDirectories.Iterator().Next();
            Sharpen.Tests.IsFalse(_directory.HasErrors());
        }
        /// <summary>
        /// Performs the XMP data extraction, adding found values to the specified instance of
        /// <see cref="Com.Drew.Metadata.Metadata"/>
        /// .
        /// <p>
        /// The extraction is done with Adobe's XMPCore library.
        /// </summary>
        public virtual void Extract([NotNull] string xmpString, [NotNull] Com.Drew.Metadata.Metadata metadata)
        {
            XmpDirectory directory = new XmpDirectory();

            try
            {
                XMPMeta xmpMeta = XMPMetaFactory.ParseFromString(xmpString);
                ProcessXmpTags(directory, xmpMeta);
            }
            catch (XMPException e)
            {
                directory.AddError("Error processing XMP data: " + e.Message);
            }
            if (!directory.IsEmpty())
            {
                metadata.AddDirectory(directory);
            }
        }
        /// <summary>Serializes the XmpDirectory component of <code>Metadata</code> into an <code>OutputStream</code></summary>
        /// <param name="os">Destination for the xmp data</param>
        /// <param name="data">populated metadata</param>
        /// <returns>serialize success</returns>
        public static bool Write(OutputStream os, Com.Drew.Metadata.Metadata data)
        {
            XmpDirectory dir = data.GetFirstDirectoryOfType <XmpDirectory>();

            if (dir == null)
            {
                return(false);
            }
            XMPMeta meta = dir.GetXMPMeta();

            try
            {
                SerializeOptions so = new SerializeOptions().SetOmitPacketWrapper(true);
                XMPMetaFactory.Serialize(meta, os, so);
            }
            catch (XMPException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
                return(false);
            }
            return(true);
        }
        /// <summary>Version specifically for dealing with XMP found in JPEG segments.</summary>
        /// <remarks>
        /// Version specifically for dealing with XMP found in JPEG segments. This form of XMP has a peculiar preamble, which
        /// must be removed before parsing the XML.
        /// </remarks>
        /// <param name="segmentBytes">The byte array from which the metadata should be extracted.</param>
        /// <param name="metadata">
        /// The
        /// <see cref="Com.Drew.Metadata.Metadata"/>
        /// object into which extracted values should be merged.
        /// </param>
        /// <param name="segmentType">
        /// The
        /// <see cref="Com.Drew.Imaging.Jpeg.JpegSegmentType"/>
        /// being read.
        /// </param>
        public virtual void Extract(sbyte[] segmentBytes, Com.Drew.Metadata.Metadata metadata, JpegSegmentType segmentType)
        {
            XmpDirectory directory = metadata.GetOrCreateDirectory <XmpDirectory>();
            // XMP in a JPEG file has a 29 byte preamble which is not valid XML.
            int preambleLength = 29;

            // check for the header length
            if (segmentBytes.Length <= preambleLength + 1)
            {
                directory.AddError(Sharpen.Extensions.StringFormat("Xmp data segment must contain at least %d bytes", preambleLength + 1));
                return;
            }
            ByteArrayReader reader   = new ByteArrayReader(segmentBytes);
            string          preamble = Sharpen.Runtime.GetStringForBytes(segmentBytes, 0, preambleLength);

            if (!"http://ns.adobe.com/xap/1.0/\x0".Equals(preamble))
            {
                directory.AddError("XMP data segment doesn't begin with 'http://ns.adobe.com/xap/1.0/'");
                return;
            }
            sbyte[] xmlBytes = new sbyte[segmentBytes.Length - preambleLength];
            System.Array.Copy(segmentBytes, 29, xmlBytes, 0, xmlBytes.Length);
            Extract(xmlBytes, metadata);
        }
        /// <summary>Reads an property value with given namespace URI and property name.</summary>
        /// <remarks>Reads an property value with given namespace URI and property name. Add property value to directory if exists</remarks>
        /// <exception cref="Com.Adobe.Xmp.XMPException"/>
        private static void ProcessXmpTag([NotNull] XMPMeta meta, [NotNull] XmpDirectory directory, int tagType, int formatCode)
        {
            string schemaNS = XmpDirectory._tagSchemaMap.Get(tagType);
            string propName = XmpDirectory._tagPropNameMap.Get(tagType);
            string property = meta.GetPropertyString(schemaNS, propName);

            if (property == null)
            {
                return;
            }
            switch (formatCode)
            {
            case FmtRational:
            {
                string[] rationalParts = property.Split("/", 2);
                if (rationalParts.Length == 2)
                {
                    try
                    {
                        Rational rational = new Rational((long)float.Parse(rationalParts[0]), (long)float.Parse(rationalParts[1]));
                        directory.SetRational(tagType, rational);
                    }
                    catch (FormatException)
                    {
                        directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as a Rational.", propName));
                    }
                }
                else
                {
                    directory.AddError("Error in rational format for tag " + tagType);
                }
                break;
            }

            case FmtInt:
            {
                try
                {
                    directory.SetInt(tagType, (int)Sharpen.Extensions.ValueOf(property));
                }
                catch (FormatException)
                {
                    directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an int.", propName));
                }
                break;
            }

            case FmtDouble:
            {
                try
                {
                    directory.SetDouble(tagType, (double)double.Parse(property));
                }
                catch (FormatException)
                {
                    directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an double.", propName));
                }
                break;
            }

            case FmtString:
            {
                directory.SetString(tagType, property);
                break;
            }

            case FmtStringArray:
            {
                //XMP iterators are 1-based
                int      count = meta.CountArrayItems(schemaNS, propName);
                string[] array = new string[count];
                for (int i = 1; i <= count; ++i)
                {
                    array[i - 1] = meta.GetArrayItem(schemaNS, propName, i).GetValue();
                }
                directory.SetStringArray(tagType, array);
                break;
            }

            default:
            {
                directory.AddError(Sharpen.Extensions.StringFormat("Unknown format code %d for tag %d", formatCode, tagType));
                break;
            }
            }
        }
Beispiel #12
0
 public virtual void SetUp()
 {
     _directory = ProcessApp1Bytes("Tests/Data/withXmpAndIptc.jpg.app1.1");
 }
Beispiel #13
0
 /// <summary>
 /// Performs the XMP data extraction, adding found values to the specified instance of
 /// <see cref="Com.Drew.Metadata.Metadata"/>
 /// .
 /// <p>
 /// The extraction is done with Adobe's XMPCore library.
 /// </summary>
 public virtual void Extract([NotNull] sbyte[] xmpBytes, [NotNull] Com.Drew.Metadata.Metadata metadata)
 {
     XmpDirectory directory = new XmpDirectory();
     try
     {
         XMPMeta xmpMeta = XMPMetaFactory.ParseFromBuffer(xmpBytes);
         ProcessXmpTags(directory, xmpMeta);
     }
     catch (XMPException e)
     {
         directory.AddError("Error processing XMP data: " + e.Message);
     }
     if (!directory.IsEmpty())
     {
         metadata.AddDirectory(directory);
     }
 }
Beispiel #14
0
 /// <exception cref="Com.Adobe.Xmp.XMPException"/>
 private static void ProcessXmpTags(XmpDirectory directory, XMPMeta xmpMeta)
 {
     // store the XMPMeta object on the directory in case others wish to use it
     directory.SetXMPMeta(xmpMeta);
     // read all the tags and send them to the directory
     // I've added some popular tags, feel free to add more tags
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLensInfo, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLens, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagCameraSerialNumber, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFirmware, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagMake, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagModel, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagExposureTime, FmtString);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagExposureProgram, FmtInt);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagApertureValue, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFNumber, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagFocalLength, FmtRational);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagShutterSpeed, FmtRational);
     ProcessXmpDateTag(xmpMeta, directory, XmpDirectory.TagDatetimeOriginal);
     ProcessXmpDateTag(xmpMeta, directory, XmpDirectory.TagDatetimeDigitized);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagRating, FmtDouble);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagLabel, FmtString);
     // this requires further research
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:title", XmpDirectory.TAG_TITLE, FMT_STRING);
     ProcessXmpTag(xmpMeta, directory, XmpDirectory.TagSubject, FmtStringArray);
     // processXmpDateTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:date", XmpDirectory.TAG_DATE);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:type", XmpDirectory.TAG_TYPE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:description", XmpDirectory.TAG_DESCRIPTION, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:relation", XmpDirectory.TAG_RELATION, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:coverage", XmpDirectory.TAG_COVERAGE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:creator", XmpDirectory.TAG_CREATOR, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:publisher", XmpDirectory.TAG_PUBLISHER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:contributor", XmpDirectory.TAG_CONTRIBUTOR, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:rights", XmpDirectory.TAG_RIGHTS, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:format", XmpDirectory.TAG_FORMAT, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:identifier", XmpDirectory.TAG_IDENTIFIER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:language", XmpDirectory.TAG_LANGUAGE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:audience", XmpDirectory.TAG_AUDIENCE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:provenance", XmpDirectory.TAG_PROVENANCE, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:rightsHolder", XmpDirectory.TAG_RIGHTS_HOLDER, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:instructionalMethod", XmpDirectory.TAG_INSTRUCTIONAL_METHOD,
     // FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualMethod", XmpDirectory.TAG_ACCRUAL_METHOD, FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualPeriodicity", XmpDirectory.TAG_ACCRUAL_PERIODICITY,
     // FMT_STRING);
     // processXmpTag(xmpMeta, directory, Schema.DUBLIN_CORE_SPECIFIC_PROPERTIES, "dc:accrualPolicy", XmpDirectory.TAG_ACCRUAL_POLICY, FMT_STRING);
     for (XMPIterator iterator = xmpMeta.Iterator(); iterator.HasNext(); )
     {
         XMPPropertyInfo propInfo = (XMPPropertyInfo)iterator.Next();
         string path = propInfo.GetPath();
         string value = propInfo.GetValue();
         if (path != null && value != null)
         {
             directory.AddProperty(path, value);
         }
     }
 }
		/// <exception cref="Com.Adobe.Xmp.XMPException"/>
		private void ProcessXmpDateTag(XMPMeta meta, XmpDirectory directory, string schemaNS, string propName, int tagType)
		{
			Sharpen.Calendar cal = meta.GetPropertyCalendar(schemaNS, propName);
			if (cal != null)
			{
				directory.SetDate(tagType, cal.GetTime());
			}
		}
		/// <summary>Reads an property value with given namespace URI and property name.</summary>
		/// <remarks>Reads an property value with given namespace URI and property name. Add property value to directory if exists</remarks>
		/// <exception cref="Com.Adobe.Xmp.XMPException"/>
		private void ProcessXmpTag(XMPMeta meta, XmpDirectory directory, string schemaNS, string propName, int tagType, int formatCode)
		{
			string property = meta.GetPropertyString(schemaNS, propName);
			if (property == null)
			{
				return;
			}
			switch (formatCode)
			{
				case FmtRational:
				{
					string[] rationalParts = property.Split("/", 2);
					if (rationalParts.Length == 2)
					{
						try
						{
							Rational rational = new Rational((long)float.Parse(rationalParts[0]), (long)float.Parse(rationalParts[1]));
							directory.SetRational(tagType, rational);
						}
						catch (FormatException)
						{
							directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as a Rational.", propName));
						}
					}
					else
					{
						directory.AddError("Error in rational format for tag " + tagType);
					}
					break;
				}

				case FmtInt:
				{
					try
					{
						directory.SetInt(tagType, Sharpen.Extensions.ValueOf(property));
					}
					catch (FormatException)
					{
						directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an int.", propName));
					}
					break;
				}

				case FmtDouble:
				{
					try
					{
						directory.SetDouble(tagType, double.Parse(property));
					}
					catch (FormatException)
					{
						directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an double.", propName));
					}
					break;
				}

				case FmtString:
				{
					directory.SetString(tagType, property);
					break;
				}

				default:
				{
					directory.AddError(Sharpen.Extensions.StringFormat("Unknown format code %d for tag %d", formatCode, tagType));
					break;
				}
			}
		}
		public virtual void SetUp()
		{
			_directory = ProcessApp1Bytes("Tests/Data/withXmpAndIptc.jpg.app1.1");
		}
        /// <summary>Reads an property value with given namespace URI and property name.</summary>
        /// <remarks>Reads an property value with given namespace URI and property name. Add property value to directory if exists</remarks>
        /// <exception cref="Com.Adobe.Xmp.XMPException"/>
        private void ProcessXmpTag(XMPMeta meta, XmpDirectory directory, string schemaNS, string propName, int tagType, int formatCode)
        {
            string property = meta.GetPropertyString(schemaNS, propName);

            if (property == null)
            {
                return;
            }
            switch (formatCode)
            {
            case FmtRational:
            {
                string[] rationalParts = property.Split("/", 2);
                if (rationalParts.Length == 2)
                {
                    try
                    {
                        Rational rational = new Rational((long)float.Parse(rationalParts[0]), (long)float.Parse(rationalParts[1]));
                        directory.SetRational(tagType, rational);
                    }
                    catch (FormatException)
                    {
                        directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as a Rational.", propName));
                    }
                }
                else
                {
                    directory.AddError("Error in rational format for tag " + tagType);
                }
                break;
            }

            case FmtInt:
            {
                try
                {
                    directory.SetInt(tagType, Sharpen.Extensions.ValueOf(property));
                }
                catch (FormatException)
                {
                    directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an int.", propName));
                }
                break;
            }

            case FmtDouble:
            {
                try
                {
                    directory.SetDouble(tagType, double.Parse(property));
                }
                catch (FormatException)
                {
                    directory.AddError(Sharpen.Extensions.StringFormat("Unable to parse XMP property %s as an double.", propName));
                }
                break;
            }

            case FmtString:
            {
                directory.SetString(tagType, property);
                break;
            }

            default:
            {
                directory.AddError(Sharpen.Extensions.StringFormat("Unknown format code %d for tag %d", formatCode, tagType));
                break;
            }
            }
        }