Reading IPTC data from Nikon camera RAW images,JPEG,TIFF files using Adobe dll in C# Reading and Writing IPTC Metadata using Adobe Photoshop DLL.
Goals:
This project is used to read and write IPTC and EXIF metadata.
Steps:
1) Create a C# project.
2) Create two button control one for read and another for write.
3) Add the reference of Adobe Photoshop Dll.
4) Add the following namespace.
using Photoshop;
5) copy the following code.
Photoshop.Document ps;
Photoshop.Application app;
Photoshop.DocumentInfo psi;
Photoshop.JPEGSaveOptionsClass jpgs;
Photoshop.TiffSaveOptionsClass tiffs;
6)In the Read button control, Copy the following code.
string iptc = "";
textBox1.Text = openFileDialog1.FileName;
app = new Photoshop.ApplicationClass();
app.Visible = false;
app.DisplayDialogs = PsDialogModes.psDisplayNoDialogs;
app.Application.Visible = false;
ps = app.Open(openFileDialog1.FileName, null);
//app.ActiveDocument = ps;
foreach (Photoshop.ArtLayer artlayerRef in ps.ArtLayers)
{
artlayerRef.Visible = false;
}
//ps.SaveAs("D:\\psaveimage", jpgs, null,2);
psi = ps.Info;
iptc = psi.Author.ToString() + "|";
iptc += psi.AuthorPosition.ToString() + "|";
iptc += psi.Caption.ToString() + "|";
iptc += psi.CaptionWriter.ToString() + "|";
iptc += psi.Category.ToString() + "|";
iptc += psi.City.ToString() + "|";
iptc += psi.CopyrightNotice.ToString() + "|";
iptc += psi.Country.ToString() + "|";
iptc += psi.CreationDate.ToString() + "|";
iptc += psi.Credit.ToString() + "|";
iptc += psi.Headline.ToString() + "|";
iptc += psi.Instructions.ToString() + "|";
iptc += psi.JobName.ToString() + "|";
//iptc += psi.Keywords.ToString() + "|";
iptc += psi.OwnerUrl.ToString() + "|";
iptc += psi.ProvinceState.ToString() + "|";
iptc += psi.Source.ToString() + "|";
//iptc += psi.SupplementalCategories.ToString() + "|";
iptc += psi.Title.ToString() + "|";
iptc += psi.TransmissionReference.ToString() + "|";
iptc += psi.Urgency.ToString() + "|";
MessageBox.Show(iptc);
object obj = new object();
obj = psi.EXIF;
MessageBox.Show(obj.ToString());
7) In the write button control, Copy the following code.
ps.Info.Copyrighted = Photoshop.PsCopyrightedType.psCopyrightedWork;
ps.Info.CopyrightNotice = "Bala@Pdi";
ps.Info.City = "Chennai";
ps.Info.Caption = "Bala";
ps.Info.Author = "Balasubramanian.S";
ps.Info.Category = "MetaData";
ps.Info.CaptionWriter = "SBala";
ps.Info.Country = "India";
ps.Info.CreationDate = "06/14/2007";
ps.Info.Headline = "IPTC";
ps.Info.Title = "IPTC Check";
ps.Info.Urgency= PsUrgency.psSeven;
ps.Save();
ps.Close(null);
ps = null;
app.Quit();
app = null;
MessageBox.Show("Data Writed Successfully"); |