Re: [PATCH] Improve date retreival from exif data



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?

--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) {
> 
> _______________________________________________
> F-spot-list mailing list
> F-spot-list gnome org
> http://mail.gnome.org/mailman/listinfo/f-spot-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]