Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read Date Photo Taken Programatically vb.net

Posted on 2011-02-23
3
Medium Priority
?
892 Views
Last Modified: 2012-08-13
I am trying to figure out how to read the metadata information from a group of Jpeg images.  I want the Date and Time the Photo was taken and the MD5 of the photo so that I can deduplicate the photos.  I have a listing of the text Files with a CR LF in Textbox1  Any help in reading the header data or information of where I can find sample code is appreciated.
0
Comment
Question by:rphilipson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:rphilipson
ID: 34964646
Meant to say I have a listing of the JPEG Files with CR LF on each line.
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34965086
This "ExifTool" looks like it will extract the jpeg metadata, and it can be used from command line.  You can call it inside a DOS "FOR /F" loop to process your "file-of-files".  This should give you a start.

http://download.cnet.com/ExifTool/3000-6675_4-10791213.html
0
 
LVL 22

Accepted Solution

by:
pivar earned 2000 total points
ID: 34965152
Hi,

Check these links:

http://msdn.microsoft.com/en-us/library/xddt0dz7.aspx
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.propertyitem.id.aspx
http://stackoverflow.com/questions/221345/how-to-get-the-file-size-of-a-system-drawing-image

Attached you'll find code to show all metadata.
Type 0x0132 is datetime

/peter
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;

namespace SimpleTest {
  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e) {
      if(openFileDialog1.ShowDialog() == DialogResult.OK) {
        textBox1.Text += openFileDialog1.FileName + Environment.NewLine;
      }
    }

    private void button2_Click(object sender, EventArgs e) {
      foreach(string filename in textBox1.Lines) {
        // Create an Image object. 
        Image image = new Bitmap(filename);

        // Get the PropertyItems property from image.
        PropertyItem[] propItems = image.PropertyItems;

        int count = 0;

        foreach(PropertyItem propItem in propItems) {
          string value = "";
          switch(propItem.Type) {
            case 1:
              value = propItem.Value[0].ToString();
              break;
            case 2:
              value = System.Text.Encoding.ASCII.GetString(propItem.Value);
              break;
            case 3:
              value = BitConverter.ToUInt16(propItem.Value, 0).ToString();
              break;
            case 4:
              value = BitConverter.ToUInt32(propItem.Value, 0).ToString();
              break;
            case 5:
              uint a1 = BitConverter.ToUInt32(propItems[count].Value, 0);
              uint b1 = BitConverter.ToUInt32(propItems[count].Value, 4);
              value = ((double)a1 / b1).ToString();
              break;
            case 9:
              // SLong
              value = Convert.ToInt32(propItem.Value).ToString();
              break;
            case 10:
              // SRational
              int a2 = BitConverter.ToInt32(propItems[count].Value, 0);
              uint b2 = BitConverter.ToUInt32(propItems[count].Value, 4);
              value = ((double)a2 / b2).ToString();
              break;

          }

          listBox1.Items.Add(String.Format("Property Item ({0}), id: 0x:{1} type: {2} length: {3} b value: {4}", count.ToString(), propItem.Id.ToString("x"),
              propItem.Type.ToString(), propItem.Len.ToString(), value
            ));
          count++;
        }
      }
    }

  }
}

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question