public void ApplyMetaDataToImageFile(string imageFilePath)
{
using (var image = new MagickImage(imageFilePath))
{
var imageWithMeta = ApplyMetaDataToImage(image);
imageWithMeta.Write(imageFilePath);
}
}
public MagickImage ApplyMetaDataToImage(MagickImage image)
{
IptcProfile iptcProfile = GetUpdatedIptcProfile(image);
ExifProfile exifProfile = GetupdatedExifProfile(image);
XmpProfile xmpProfile = GetUpdatedXmpProfile(image);
if (iptcProfile != null)
{
image.AddProfile(iptcProfile);
}
if (exifProfile != null)
{
image.AddProfile(exifProfile);
}
if (xmpProfile != null)
{
image.AddProfile(xmpProfile);
}
return image;
}
private IptcProfile GetUpdatedIptcProfile(MagickImage image)
{
IptcProfile iptcProfile = image.GetIptcProfile() ?? new IptcProfile();
iptcProfile.SetValue(IptcTag.Byline, Creator);
// Alternative label advocated by the older IPTC IIM schema, used for "Creator."
iptcProfile.SetValue(IptcTag.Headline, Headline);
iptcProfile.SetValue(IptcTag.CopyrightNotice, CopyrightNotice);
return iptcProfile;
}
↧
New Post: IPTC data unreadable
↧