ValueError: timestamp out of range for platform time_t

97 views
Skip to first unread message

toastersocks

unread,
Aug 14, 2009, 7:46:24 PM8/14/09
to iphotoexport-users
Hi, first I want to say thanks for such a great program! It was
exactly the sort of thing I was looking for.
However when I try to use iphotoexport.py, for instance
./iphotoexport.py -a "test" ~/Pictures/iPhoto\ Library/ ~/Desktop/
iphotoexporttest/
I get this error:
Traceback (most recent call last):
File "./iphotoexport.py", line 641, in <module>
main()
File "./iphotoexport.py", line 632, in main
data = iphotodata.get_iphoto_data(library_dir, album_xml_file,
options.faces)
File "/Users/jambes/Desktop/iphotoexport-1.2/appledata/
iphotodata.py", line 411, in get_iphoto_data
data = IPhotoData(album_xml)
File "/Users/jambes/Desktop/iphotoexport-1.2/appledata/
iphotodata.py", line 67, in __init__
image = IPhotoImage(image_data.get(key), self.keywords)
File "/Users/jambes/Desktop/iphotoexport-1.2/appledata/
iphotodata.py", line 229, in __init__
self.date = applexml.getappletime(data.get("DateAsTimerInterval"))
File "/Users/jambes/Desktop/iphotoexport-1.2/appledata/applexml.py",
line 32, in getappletime
return datetime.datetime.fromtimestamp(APPLE_BASE + float(value))
ValueError: timestamp out of range for platform time_t

What can I do?
Any help is much appreciated!
Thanks

Tilman Sporkert

unread,
Aug 15, 2009, 12:59:08 AM8/15/09
to iphotoexp...@googlegroups.com
Sorry about that. I'll look into it a bit tomorrow. Did you make any changes to the code? Just wondering, because the line number (line 32, in getappletime) doesn't match with my copy of the code.

If you are desperate, and are OK with editing code, you can just change the function in appledata/applexml.py. This is how it looks now:

def getappletime(value):
  '''Converts a numeric Apple time stamp into a date and time'''
  return datetime.datetime.fromtimestamp(APPLE_BASE + float(value))

Change it to:

def getappletime(value):
  '''Converts a numeric Apple time stamp into a date and time'''
  return datetime.datetime.fromtimestamp(APPLE_BASE)

This will assign the wrong time to all your images, but unless you use the "-k" or "-K" options, the image timestamps is not used.

Tilman

toastersocks

unread,
Aug 15, 2009, 1:46:51 AM8/15/09
to iphotoexport-users
Thanks for the quick reply! I've since discovered that the error was
caused by a few of my photos having EXIF dates way far in the future,
somehow. I striped out the date info from those files and it now works
fine. And yeah I had added a few lines to try and debug the problem.
Thanks for looking into it. :) Also, about exporting utf-8 characters
in comments and keywords, I don't know if you already have a fix in
the works for this or not, but I made a small change which will
correctly export these characters. In tilutil/exiftool.py line 101:

command = [_EXIFTOOL, '-F', '-P', '-ImageDescription=']

I added the -codedcharset=utf8 option:

command = [_EXIFTOOL, '-codedcharacterset=utf8', '-F', '-P', '-
ImageDescription=']

I'm not sure how to submit this the "proper" way, but I hope it helps!

Tilman Sporkert

unread,
Aug 15, 2009, 3:35:52 AM8/15/09
to iphotoexp...@googlegroups.com
Thanks for figuring out the problem with the dates. Now that I know
what the problem is, I'll see if I can work a fix into the code.

I have done some work for better Unicode support, however I ended up
with a slightly different solution. I added:
-iptc:CodedCharacterSet=ESC % G
to the exiftool invocation. It did some experimentation with
Photoshop, Picasa Mac, Flickr, PicasaWeb, etc., and that seemed to
have worked pretty well.

Tilman

Tilman

unread,
Sep 2, 2009, 1:22:17 PM9/2/09
to iphotoexport-users
I just uploaded iphotoexport-1.3.1, which should address this problem.

Tilman
Reply all
Reply to author
Forward
0 new messages