I have an application which analyses images. I have to retreive the Date Taken of an image. I use this function :
var r = new Regex(":");
var myImage = LoadImageNoLock(path);
{
PropertyItem propItem = null;
try
{
propItem = myImage.GetPropertyItem(36867);
}
catch{
try
{
propItem = myImage.GetPropertyItem(306);
}
catch { }
}
if (propItem != null)
{
var dateTaken = r.Replace(Encoding.UTF8.GetString(propItem.Value), "-", 2);
return DateTime.Parse(dateTaken);
}
else
{
return null;
}
}
My application worked well with photos taken by a Camera. But now, I save photos from a Webcam like this :
private void Webcam_PhotoTakenEvent(Bitmap inImage)
{
// Save photo on disk
if (_takePhoto == true)
{
// Save the photo on disk
inImage.Save(_currentPath + "/BV_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".jpeg");
}
}
In this case, my previous function does not work because the image file does not contain any PropertyItem.
Is there any way to retreive the date taken by the PropertyItem when we save the image manually?
Thanks in advance.