Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am having a bit of a confusing issue with PropertyItems[] and parsing EXIF data from images...

 

 private void test()
       {
           int tagMake = 0x010F;  // 271
           int tagModel = 0x0110; // 272

           Image image = Image.FromFile("C:\\test3.jpg");

           byte[] make = image.PropertyItems.Single(x => x.Id == tagMake).Value;
           byte[] model = image.PropertyItems.Single(x => x.Id == tagModel).Value;

           var encoding = new System.Text.ASCIIEncoding();

           Trace.WriteLine(encoding.GetString(make)); 
           Trace.WriteLine(encoding.GetString(model)); 
       }

 

The above returns these two tags from *some* images, some it errors and says that they are not there. for instance I can download sample images with EXIF data from the internet, and parse this information without any apparent issue.

 

The images that are in error come from two android devices, one is an HTC One, the other a Note 3.

 

However on all those images it does not report those fields on, all other EXIF editors I can find *do* show them there, and with the correct ID.

 

Likewise just cycling through shows many other tags, but never those two (perhaps missing more, I have not compared them all)

 

    Image Img;
           Img = new Bitmap("C:\\test3.jpg");
           foreach (PropertyItem item in Img.PropertyItems)
           {
               Trace.WriteLine(item.Id);
           }

 

Shows just about everything *but* those tags...:confused:

 

So the main question is why other editors locate them without issue, but .NET consistently fails to see them?

Life is a comedy to those who think; a tragedy to those who feel.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...