How do I replace the IPTCT metadata
Posted: 2011-08-22T01:41:42-07:00
I am attempting to remove the existing IPTC metadata from an image and then add my own so that I can set author, byline and copyright information.
I am programming in Delphi and have succeeded in reading in an image, resizing it, and then writing it back out to a new location so I am calling the ImageMagick API successfully. It is the IPTC meta data which is defeating me. Here is what I have written in my code:
I have proved this works in that when I remove the profile the count of profiles goes down by one. The contents of the profile returned by MagickRemoveImageProfile() are correct (they contain the original data). The IPTC array contains my new metadata, I can read that back using GetImageProfile() and it contains the new data. However, when I save the file it still contains the original data.
This is how I write the file:
Where am I going wrong?
I am programming in Delphi and have succeeded in reading in an image, resizing it, and then writing it back out to a new location so I am calling the ImageMagick API successfully. It is the IPTC meta data which is defeating me. Here is what I have written in my code:
Code: Select all
pansi := MagickRemoveImageProfile(Wand, PAnsiChar('IPTC'), @len);
if pansi = nil then
Exit;
Result := MagickSetImageProfile(Wand, PAnsiChar('IPTC'), @IPTC[0], length(IPTC)) = MagickTrue;
This is how I write the file:
Code: Select all
Result := MagickWriteImages(Wand, PAnsiChar(AnsiName), MagickFalse) = MagickTrue;