This project has moved and is read-only. For the latest updates, please go here.

Overwrite iptc profile

Apr 14, 2014 at 9:46 PM
Edited Apr 14, 2014 at 9:48 PM
Im trying to overwrite the IPTC profile on an image but it seems to not apply the changes. For example a simple test:
                    using (fs = fnfFotoMedia.Open(FileMode.Open, FileAccess.ReadWrite))
                        using (MagickImage image = new MagickImage(fs))

                            var profile = image.GetIptcProfile();
                             // remove the profile

                   //open the saved image
                   using (MagickImage image = new MagickImage(new FileInfo("C://teste.jpg").OpenRead()))
                       var profile = image.GetIptcProfile(); //profile is not null
What im doing wrong?
Apr 15, 2014 at 11:44 AM
Edited Apr 15, 2014 at 12:43 PM
I can reproduce the issue. It looks like a bug in Imagemagick. I will have to investigate this for you. Have you tried to just add your new profile? It should overwrite an existing profile.
Apr 15, 2014 at 5:27 PM
Edited Apr 15, 2014 at 5:32 PM
Yes I tried, but got the same results it seems not be writing with the current image profile.
Even if I get the image.GetByteArray() and write a new file with those bytes it wont work. The bytes stays the same before and after I change the profile (actually, not sure if it was supose to change).
Apr 15, 2014 at 7:42 PM
I figured out why this is not working. The iptc profile is actually stored inside the 8bim profile. And the changes in the IPTC profiles are not stored in the 8bim profile. I will have to add this feature/fix to ImageMagick for you.

A workaround for now would be to also remove the 8BIM profile. This will create a new 8BIM profile that contains your new iptc profile.
Apr 21, 2014 at 10:39 PM
I just committed a patch to the ImageMagick repository. This issue will be resolved in the next release of Magick.NET.
Apr 24, 2014 at 2:45 PM
Apr 24, 2014 at 2:52 PM
That commit is not there, it is in the repository of ImageMagick. I did not rebuild Magick.NET yet with the new source code of ImageMagick. If this is really urgent for you (next release will be tomorrow or this weekend) then please contact me through CodePlex from my profile page and I can send you a development build.