The IPTC Information Interchange Model (IIM) is a set of metadata properties that can be applied to text, images, and other media types. The standard also defines a complex data structure that is utilized to store the properties. The IPTC IIM was developed by the International Press Telecommunications Council (IPTC) to expedite the international exchange of news among newspapers and news agencies. But nowadays it’s commonly used by amateur and commercial photographers. The standard is supported by many image creation and manipulation programs. IPTC IIM metadata can be embedded into a variety of image formats such as JPEG, TIFF, etc.
Note
For more information on the IPTC IIM standard please refer to https://www.iptc.org/std/IIM/4.2/specification/IIMV4.2.pdf.
Reading basic IPTC IIM properties
To access IPTC metadata in a file of any supported format, GroupDocs.Metadata provides the IIptc.IptcPackage property. The following are the steps to read IPTC metadata:
In some cases, it’s necessary to read all IPTC datasets (metadata properties) from a file, including custom ones. To achieve this the GroupDocs.Metadata API provides direct access to the IPTC datasets extracted from a file.
The GroupDocs.Metadata API facilitates the user to update IPTC metadata in a convenient way - using the IptcRecordSet class properties. Follow the below steps to update IPTC metadata in a file of any supported format.
using(Metadatametadata=newMetadata(Constants.InputJpeg)){IIptcroot=metadata.GetRootPackage()asIIptc;if(root!=null){// Set the IPTC package if it's missingif(root.IptcPackage==null){root.IptcPackage=newIptcRecordSet();}if(root.IptcPackage.EnvelopeRecord==null){root.IptcPackage.EnvelopeRecord=newIptcEnvelopeRecord();}root.IptcPackage.EnvelopeRecord.DateSent=DateTime.Now;root.IptcPackage.EnvelopeRecord.ProductID=Guid.NewGuid().ToString();// ...if(root.IptcPackage.ApplicationRecord==null){root.IptcPackage.ApplicationRecord=newIptcApplicationRecord();}root.IptcPackage.ApplicationRecord.ByLine="GroupDocs";root.IptcPackage.ApplicationRecord.Headline="test";root.IptcPackage.ApplicationRecord.ByLineTitle="code sample";root.IptcPackage.ApplicationRecord.ReleaseDate=DateTime.Today;// ...metadata.Save(Constants.OutputJpeg);}}
Adding or updating custom IPTC IIM datasets
The GroupDocs.Metadata API allows adding or updating custom datasets in an IPTC package.
using(Metadatametadata=newMetadata(Constants.PsdWithIptc)){IIptcroot=metadata.GetRootPackage()asIIptc;if(root!=null){// Set the IPTC package if it's missingif(root.IptcPackage==null){root.IptcPackage=newIptcRecordSet();}// Add a know property using the DataSet APIroot.IptcPackage.Set(newIptcDataSet((byte)IptcRecordType.ApplicationRecord,(byte)IptcApplicationRecordDataSet.BylineTitle,"test code sample"));// Add a custom IPTC DataSetroot.IptcPackage.Set(newIptcDataSet(255,255,newbyte[]{1,2,3}));metadata.Save(Constants.OutputPsd);}}
Adding repeatable IPTC IIM datasets
According to the IPTC IIM specification some datasets can be added to a record multiple times. The code snippet below demonstrates how to add a repeatable dataset to a record.
using(Metadatametadata=newMetadata(Constants.PsdWithIptc)){IIptcroot=(IIptc)metadata.GetRootPackage();// Set the IPTC package if it's missingif(root.IptcPackage==null){root.IptcPackage=newIptcRecordSet();}root.IptcPackage.Add(newIptcDataSet((byte)IptcRecordType.ApplicationRecord,(byte)IptcApplicationRecordDataSet.Keywords,"keyword 1"));root.IptcPackage.Add(newIptcDataSet((byte)IptcRecordType.ApplicationRecord,(byte)IptcApplicationRecordDataSet.Keywords,"keyword 2"));root.IptcPackage.Add(newIptcDataSet((byte)IptcRecordType.ApplicationRecord,(byte)IptcApplicationRecordDataSet.Keywords,"keyword 3"));metadata.Save(Constants.OutputPsd);}// Check the output fileusing(Metadatametadata=newMetadata(Constants.OutputPsd)){IIptcroot=(IIptc)metadata.GetRootPackage();varkeywordsProperty=root.IptcPackage.ApplicationRecord[(byte)IptcApplicationRecordDataSet.Keywords];foreach(varvalueinkeywordsProperty.Value.ToArray<PropertyValue>()){Console.WriteLine(value);}}
Removing IPTC IIM metadata
To remove the IPTC package from a file just assign null to the IIptc.IptcPackage property. The code sample below shows how to remove IPTC metadata from a file.
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.