How to read propertyItem from Jpeg file Set with Windows Explorer.
I have been trying to read property item set by windows explorer (Windows
XP) they are Title and Comments On Jpeg Image.
This properties are set by Windows XP as
Title : Type 1(unsigned byte) and Id 0x9c9b (40091)
Comments : Type 1(unsigned byte) and Id 0x9c9c (40092)
Now the problem how to read those properties correctly. I am getting some
unknow characters added when i get values which makes those values unusable
for display. may be i am doing some thing wrong for reading PropertyItem
value, but i am yet to see any third party tool that displays those value
correctly.
I would appreciate if any body can show correct way to read those values.
String Title = "";
String Comments = "";
using (System.Drawing.Image img = System.Drawing.Image.FromFile(filename)) {
try{
foreach (System.Drawing.Imaging.PropertyItem pi in
img.PropertyItems) {
if (pi.Id == TitleId) {
Title = System.Text.Encoding.ASCII.GetString(pi.Value);
}else if(pi.Id == DescriptionId){
Comments = System.Text.Encoding.ASCII.GetString(pi.Value);
}
}
}catch(Exception ex){
}
}
Another serious problem is when you set those properties on Windows2000
server using file explorer and try to read using following code is gives
error stating object refrence not set (meaning it does some thing wrong with
PropertyItems and are no more readable.)