On Thu, 2005-04-28 at 23:33 -0500, Larry Ewing wrote: > I'm a little confused by this patch, why are you commenting out the code > in Reset? I can't see anywhere that code would be touched during > import. Also I'd expect the entry to be null not the entry.Value in the > second part of the patch. Can you send me one of the photos that is > getting the wrong date so I can look into it more? In GetEntry: ExifEntry entry = Lookup (tag); if (entry == null) entry = new ExifEntry (this, tag); and: public ExifEntry (ExifContent parent, ExifTag tag) { handle = new HandleRef (this, exif_entry_new ()); parent.Add (this); this.Reset (tag); } So, if I understand this all correctly, it means it would trigger the (code I removed) that created the entry with the current date. So, switching to Lookup for all but the last call makes sure that the ExifEntry isn't created until we exhaust all possible options (the last one being a GetEntry). I don't know why it just can't be entry==null. But it doesn't work for me that way (i have to use entry.Value). I will send you the photo(s) privately, along with the stat info. > > --Larry > > On Tue, 2005-04-26 at 17:22 +1000, Stewart Smith wrote: > > While importing my photo library, I noticed that some photos were > > getting the current date instead of the date that they were taken. > > > > It turns out that a bunch of my photos only have DateTime set, and not > > DateTimeOriginal. > > > > The following patch tries to get the date from exif data like so: > > DateTimeOriginal > > DateTime > > DateTimeDigitized > > > > It may not be perfect. This is the first C#/Mono code i have ever > > written. > > > > diff -u -r1.9 Exif.cs > > --- src/Exif.cs 25 Mar 2005 04:45:59 -0000 1.9 > > +++ src/Exif.cs 26 Apr 2005 07:18:06 -0000 > > @@ -480,13 +480,6 @@ > > } > > > > exif_entry_initialize (handle, tag); > > - > > - //FIXME the month string in time fields in libexif ix currently broken so we do our own. > > - if (tag == ExifTag.DateTime > > - || tag == ExifTag.DateTimeOriginal > > - || tag == ExifTag.DateTimeDigitized) > > - this.SetData (System.DateTime.Now); > > - > > } > > > > > > diff -u -r1.59 PhotoStore.cs > > --- src/PhotoStore.cs 30 Mar 2005 04:25:27 -0000 1.59 > > +++ src/PhotoStore.cs 26 Apr 2005 07:18:09 -0000 > > @@ -517,8 +517,12 @@ > > try { > > using (Exif.ExifData ed = new Exif.ExifData (path)) { > > Exif.ExifContent content = ed.GetContents (Exif.ExifIfd.Exif); > > - Exif.ExifEntry entry = content.GetEntry (Exif.ExifTag.DateTimeOriginal); > > - time = Exif.ExifUtil.DateTimeFromString (entry.Value); > > + Exif.ExifEntry entry = content.Lookup (Exif.ExifTag.DateTimeOriginal); > > + if (entry.Value==null) > > + entry = content.GetEntry (Exif.ExifTag.DateTime); > > + if (entry.Value==null) > > + entry = content.GetEntry (Exif.ExifTag.DateTimeDigitized); > > + time = Exif.ExifUtil.DateTimeFromString (entry.Value); > > time = time.ToUniversalTime (); > > } > > } catch (System.Exception e) { > > -- Stewart Smith (stewart flamingspork com) http://www.flamingspork.com/
Attachment:
signature.asc
Description: This is a digitally signed message part