This project has moved. For the latest updates, please go here.

update tags/keywords in all (xmp, exif, iptc) profiles..

Aug 16, 2014 at 3:13 AM
nuget Magick.NET-q16-anyCPU version the title suggest, i am trying to update all the "tags/keywords" for a given jpg...

my implementation does not give any errors, but the properties of the jpg remain unchanged- that is if i rightclick>properties the jpeg and inspect the details tag, neither the keywords not the tile are updated...

is there some final "commit" or "save" that i have to perform to make the profile apply?

thanks in advance.
private void button1_Click(object sender, EventArgs e)
            var result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
                // select the "parent folder" that contains all the subfolders, that contains images w/in...
                foreach (var path in Directory.EnumerateDirectories(folderBrowserDialog1.SelectedPath))
                    // get the current folder in loop.......
                    var folderInfo = new FileInfo(path);

                    foreach (var jpeg in Directory.EnumerateFiles(path, "*.jpg"))
                            // set the "keyWord" to the first 8 characters of the folder that "this" image is in...
                            var keyWord = folderInfo.Name.Substring(0, 8);

                            //AddTags(jpeg, tagSet);
                            UseMagick(jpeg, keyWord);
                        catch (Exception ex)
                            // write exception handler 

        private void UseMagick(string imagePath, string keyWord)
            using (ImageMagick.MagickImage image = new ImageMagick.MagickImage(imagePath))
                IptcProfile updatedIptcProfile;
                ExifProfile updatedExifProfile;

                // attempt to get the profile(s)...
                updatedIptcProfile = image.GetIptcProfile();
                updatedExifProfile = image.GetExifProfile();

                // if the profile(s) are null, create a new one; otherwise use existing profile data...
                updatedIptcProfile = (updatedIptcProfile == null ? new IptcProfile() : updatedIptcProfile);
                updatedExifProfile = (updatedExifProfile == null ? new ExifProfile() : updatedExifProfile);

                // update the various stuff
                updatedIptcProfile.SetValue(IptcTag.Title, "Testing Adding Title");
                updatedIptcProfile.SetValue(IptcTag.Keyword, keyWord);
                updatedIptcProfile.SetValue(IptcTag.Caption, "image magick");


                var updatedProfile = image.GetIptcProfile();
Aug 16, 2014 at 9:49 AM
I don't see you calling image.Write() in your using block? All operations on the image are not saved until you write the image to disk again.