Hi, here is some code I've been using for that purpose, it was aiming at JPEG though:
FileStream stream=new FileStream(fileSpec, FileMode.Open, FileAccess.Read);
//File.OpenRead(fileSpec);
Image localImage2=Image.FromStream(stream);
#if true
int[] piList=localImage2.PropertyIdList;
Dictionary<int, string> propNames=new Dictionary<int,string>();
propNames.Add(0x010E, "ImageDescription");
propNames.Add(0x010F, "EquipMake");
propNames.Add(0x0110, "EquipModel");
propNames.Add(0x0112, "Orientation");
propNames.Add(0x011A, "XResolution");
propNames.Add(0x011B, "YResolution");
propNames.Add(0x0132, "DateTime");
propNames.Add(0x0128, "ResolutionUnit");
propNames.Add(0x0131, "SoftwareUsed");
propNames.Add(0x0201, "JPEGInterFormat");
propNames.Add(0x0202, "JPEGInterLength");
propNames.Add(0x0213, "YCbCrPositioning");
propNames.Add(0x501B, "ThumbnailData");
propNames.Add(0x502D, "ThumbnailResolutionX");
propNames.Add(0x502E, "ThumbnailResolutionY");
propNames.Add(0x5090, "LuminanceTable");
propNames.Add(0x5091, "ChrominanceTable");
propNames.Add(0x829A, "ExifExposureTime");
propNames.Add(0x9003, "ExifDTOrig");
propNames.Add(0x9004, "ExifDTDigitized");
propNames.Add(0x9204, "ExifExposureBias");
propNames.Add(0x9209, "ExifFlash");
propNames.Add(0x927C, "ExifMakerNote");
propNames.Add(0x9286, "ExifUserComment");
propNames.Add(0xA002, "ExifPixXDim");
propNames.Add(0xA003, "ExifPixYDim");
foreach (int ID in piList) {
//if (propNames[ID]==null) getPropertyItem(localImage2, ID, propNames);
if (propNames.ContainsKey(ID)) getPropertyItem(localImage2, ID, propNames);
}
#endif
// we now create a copy, so we can close the filestream
// MSDN says: You must keep the stream open for the lifetime of the Image object.
// see also the article "PRB: Image File Is Locked When You Set the PictureBox
// Image Property to a File"
localImage=new Bitmap(localImage2);
stream.Close();
localImage2.Dispose();
and
protected void getPropertyItem(Image image, int ID, Dictionary<int, string> propNames) {
string s=(string)propNames[ID];
if (s==null) s="";
s+=new string(' ', 20);
s=s.Substring(0, 20);
string name="Prop"+LP_Format.Hex4(ID)+" "+s;
string type=null;
try {
PropertyItem pi=image.GetPropertyItem(ID);
s="";
byte[] bb=pi.Value;
switch ((PropertyTagType)pi.Type) {
case PropertyTagType.Byte:
type="(byte)";
for (int i=0; i<bb.Length; i++) {
byte us=bb[i];
s+=" "+us