public void Test_ExifTag()
        {
            var exifProfile = new ExifProfile();

            exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1);
            ExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit);

            Assert.AreEqual("None", value.ToString());

            exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)2);
            value = exifProfile.GetValue(ExifTag.ResolutionUnit);
            Assert.AreEqual("Inches", value.ToString());

            exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)3);
            value = exifProfile.GetValue(ExifTag.ResolutionUnit);
            Assert.AreEqual("Centimeter", value.ToString());

            exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)4);
            value = exifProfile.GetValue(ExifTag.ResolutionUnit);
            Assert.AreEqual("4", value.ToString());

            exifProfile.SetValue(ExifTag.ImageWidth, 123);
            value = exifProfile.GetValue(ExifTag.ImageWidth);
            Assert.AreEqual("123", value.ToString());
        }
        public void setAllValues(ExifValue value, Image image)
        {
            string hold = value.ToString();

            if (value.Tag.ToString().Equals("GPSLatitudeRef"))
            {
                image.GPSLatitudeRef = hold[0];
            }
            else if (value.Tag.ToString().Equals("GPSLatitude"))
            {
                image.GPSLatitude    = hold;
                image.LatitudeDegree = parseDegree(hold);
                image.LatitudeMinute = parseMinute(hold);
                image.LatitudeSecond = parseSecond(hold);
            }
            else if (value.Tag.ToString().Equals("GPSLongitudeRef"))
            {
                image.GPSLongitudeRef = hold[0];
            }
            else if (value.Tag.ToString().Equals("GPSLongitude"))
            {
                image.GPSLongitude    = hold;
                image.LongitudeDegree = parseDegree(hold);
                image.LongitudeMinute = parseMinute(hold);
                image.LongitudeSecond = parseSecond(hold);
            }
            else if (value.Tag.ToString().Equals("DateTime"))
            {
                image.photoDate = convertDateTime(hold);
            }
        }
        public string getImageComment(string jpegFileInputPath)
        {
            string result = null;

            if (!File.Exists(jpegFileInputPath))
            {
                log.Error(String.Format("File does not exist. File : {0}.", jpegFileInputPath));
            }
            else
            {
                try
                {
                    using (MagickImage image = new MagickImage(jpegFileInputPath))
                    {
                        ExifProfile profile = image.GetExifProfile();

                        ExifValue value = profile.GetValue(ExifTag.ImageDescription);

                        result = value.ToString();
                    }
                }
                catch (Exception ex)
                {
                    log.Error(String.Format("Problem reading comments from file \"{0}\". Exception : {1}.", jpegFileInputPath, ex));
                }
            }

            return(result);
        }
            public void ShouldSetTheProperties()
            {
                var value = new ExifValue(ExifTag.ImageDescription, ExifDataType.Ascii, "Communications", false);

                Assert.AreEqual(ExifDataType.Ascii, value.DataType);
                Assert.AreEqual(ExifTag.ImageDescription, value.Tag);
                Assert.AreEqual(false, value.IsArray);
                Assert.AreEqual("Communications", value.ToString());
            }
Beispiel #5
0
        public void Test_Properties()
        {
            ExifValue value = GetExifValue();

            Assert.AreEqual(ExifDataType.Ascii, value.DataType);
            Assert.AreEqual(ExifTag.ImageDescription, value.Tag);
            Assert.AreEqual(false, value.IsArray);
            Assert.AreEqual("Communications", value.ToString());
            Assert.AreEqual("Communications", value.Value);
        }
Beispiel #6
0
        public void Properties()
        {
            ExifValue value = GetExifValue();

            Assert.Equal(ExifDataType.Ascii, value.DataType);
            Assert.Equal(ExifTag.GPSDOP, value.Tag);
            Assert.False(value.IsArray);
            Assert.Equal("Windows Photo Editor 10.0.10011.16384", value.ToString());
            Assert.Equal("Windows Photo Editor 10.0.10011.16384", value.Value);
        }
Beispiel #7
0
        public void Test_UnknownExifTag()
        {
            var exifProfile = new ExifProfile();

            exifProfile.SetValue(ExifTag.ImageWidth, 42);

            var bytes = exifProfile.ToByteArray();

            bytes[16] = 42;

            exifProfile = new ExifProfile(bytes);

            ExifTag   unkownTag = (ExifTag)298;
            ExifValue value     = exifProfile.GetValue(unkownTag);

            Assert.AreEqual(42, value.Value);
            Assert.AreEqual("42", value.ToString());

            bytes = exifProfile.ToByteArray();
            Assert.AreEqual(0, bytes.Length);
        }
 private static void TestRationalValue(ExifValue value, string expected)
 {
     Assert.IsNotNull(value);
     Assert.AreEqual(expected, value.ToString());
 }
            public void ShouldReturnTheValueAsString()
            {
                var value = new ExifValue(ExifTag.ImageWidth, ExifDataType.SignedShort, (short)42, false);

                Assert.AreEqual("42", value.ToString());
            }
Beispiel #10
0
 private static void TestRationalValue(ExifValue value, string expected)
 {
   Assert.IsNotNull(value);
   Assert.AreEqual(expected, value.ToString());
 }