This project has moved. For the latest updates, please go here.

GetAttribute date:create returns current time instead of file creation time

Nov 21, 2016 at 9:40 PM
Edited Nov 21, 2016 at 9:41 PM

I'm trying to read the metadata from an image file. The library can't seem to get an exif profile, so to get around it, I'm using MagickImage.GetAttribute instead. I'm passing int "date:create" to the attribute, but somehow this always returns me the current time when that image was read. This is different when I'm reading the image from image magick command line. Image magick CLI gives me a constant time equal to the timestamp stored by the filesystem to the file.
                exifDict = new Dictionary<ExifTag, string>
                    { ExifTag.DateTime, image.GetAttribute("date:create") },
Here's the link to the file I'm testing:!FxJHzSyT!ujV6vNaHyYx09Ql2mIghgarYTYbZH9fPmpQlihSSzRE
Nov 22, 2016 at 5:06 AM
Are you reading from a stream or from a file?
Nov 22, 2016 at 2:47 PM
Nov 22, 2016 at 9:34 PM
Edited Nov 22, 2016 at 10:02 PM
When the image is read from a stream it has no clue about the original file. This means it cannot determine when the image was created and it will use the current time. But I don't understand why the following code works though:
using (MagickImage image = new MagickImage(@"d:\caspian.tif"))
  var dateTimeOriginal = image.GetAttribute("exif:DateTimeOriginal");
It appears that the image has exif information but not exif profile. I will take another look at it this weekend and figure out why.
Nov 22, 2016 at 10:59 PM
That would be great. The discrepancy between no exif profile and having the exif attribute has been a big mystery to me throughout my usage of this library.
Nov 28, 2016 at 8:45 PM
It appears the exif information is stored a bit odd inside the TIFF file format. I don't think it will be easy to read it and store it in the "normal" exif format though. I think you will need to use the GetAttribute solution in this situation.