Beispiel #1
0
        /// <param name="context"></param>
        /// <param name="magickImage"></param>
        public void Execute(PipelineContext context, MagickImage magickImage)
        {
            StringInterpolator interpolator = Interpolator.Branch(context.ResolvedData, magickImage);
            IIptcProfile       iptcProfile  = magickImage.GetIptcProfile() ?? new IptcProfile();

            IEnumerable <TagConfig <IptcTag> > tags = new List <TagConfig <IptcTag> >();

            if (Config.Defaults)
            {
                tags = tags.Concat(DefaultIptcTags);
            }

            if (Config.Iptc != null)
            {
                tags = tags.Concat(Config.Iptc);
            }

            foreach (TagConfig <IptcTag> tag in tags)
            {
                string value = interpolator.Interpolate(tag.Value);
                iptcProfile.SetValue(tag.Tag, value);
            }

            magickImage.SetProfile(iptcProfile);
            context.Next(magickImage);
        }
Beispiel #2
0
        private static void TestValue(IIptcProfile profile, IptcTag tag, string expectedValue)
        {
            var value = profile.GetValue(tag);

            Assert.IsNotNull(value);
            Assert.AreEqual(expectedValue, value.Value);
        }
Beispiel #3
0
        private static void TestProfileValues(IIptcProfile profile, int count)
        {
            Assert.IsNotNull(profile);

            Assert.AreEqual(count, profile.Values.Count());

            foreach (IptcValue value in profile.Values)
            {
                Assert.IsNotNull(value.Value);
            }
        }
Beispiel #4
0
        /// <summary>
        /// persist existing metadata values (if any) to property values
        /// </summary>
        private void Init()
        {
            IExifProfile exifprofile = _image.GetExifProfile();

            if (!exifprofile.IsNull())
            {
                if (exifprofile.GetValue(ExifTag.Copyright) != null)
                {
                    Copyright = exifprofile.GetValue(ExifTag.Copyright).ToString();
                }
                if (exifprofile.GetValue(ExifTag.Artist) != null)
                {
                    Creator = exifprofile.GetValue(ExifTag.Artist).ToString();
                }
                if (exifprofile.GetValue(ExifTag.ImageDescription) != null)
                {
                    Subject = exifprofile.GetValue(ExifTag.ImageDescription).ToString();
                }
                if (exifprofile.GetValue(ExifTag.Software) != null)
                {
                    Software = exifprofile.GetValue(ExifTag.Software).ToString();
                }
            }
            IIptcProfile iptcprofile = _image.GetIptcProfile();

            if (!iptcprofile.IsNull())
            {
                if (iptcprofile.GetValue(IptcTag.Country) != null)
                {
                    Country = iptcprofile.GetValue(IptcTag.Country).ToString();
                }
                if (iptcprofile.GetValue(IptcTag.Headline) != null)
                {
                    Headline = iptcprofile.GetValue(IptcTag.Headline).ToString();
                }
                if (iptcprofile.GetValue(IptcTag.Keyword) != null)
                {
                    Keywords = iptcprofile.GetValue(IptcTag.Keyword).ToString();
                }
                if (iptcprofile.GetValue(IptcTag.Source) != null)
                {
                    Source = iptcprofile.GetValue(IptcTag.Source).ToString();
                }
                if (iptcprofile.GetValue(IptcTag.Caption) != null)
                {
                    Subject = iptcprofile.GetValue(IptcTag.Caption).ToString();
                }
                if (iptcprofile.GetValue(IptcTag.Title) != null)
                {
                    Title = iptcprofile.GetValue(IptcTag.Title).ToString();
                }
            }
        }
Beispiel #5
0
 private static void TestProfileValues(IIptcProfile profile) => TestProfileValues(profile, 18);