Browse Source

Allow specification of local path to photo.

debian-sid
Tom Payne 14 years ago
parent
commit
eb27646e81
  1. 16
      igc2kmz/photo.py

16
igc2kmz/photo.py

@ -26,16 +26,16 @@ import exif
class Photo(object):
def __init__(self, url):
components = urlparse.urlparse(url)
def __init__(self, url, path=None):
self.url = url
components = urlparse.urlparse(self.url)
self.name = os.path.splitext(os.path.basename(components.path))[0]
if components.scheme:
self.url = url
if path:
file = open(path)
else:
self.url = 'file://' + os.path.realpath(url)
file = urllib2.urlopen(self.url)
if file.info().typeheader != 'image/jpeg':
raise RuntimeError, '%s: not an image/jpeg' % self.url
file = urllib2.urlopen(self.url)
if file.info().typeheader != 'image/jpeg':
raise RuntimeError, '%s: not an image/jpeg' % self.url
self.jpeg = exif.JPEG(file)
if 'DateTimeOriginal' in self.jpeg.exif:
self.dt = exif.parse_datetime(self.jpeg.exif['DateTimeOriginal'])

Loading…
Cancel
Save