diff options
Diffstat (limited to 'bn_django/photos/views.py')
-rw-r--r-- | bn_django/photos/views.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bn_django/photos/views.py b/bn_django/photos/views.py index bc8a3a4..cf165cd 100644 --- a/bn_django/photos/views.py +++ b/bn_django/photos/views.py @@ -103,6 +103,7 @@ def import_photos(request, thegallery): continue photo = file(photopath, "wb") photo.write(data) + f = photo # Create the object if photopath.startswith(os.path.sep): @@ -111,6 +112,23 @@ def import_photos(request, thegallery): photographer=new_data['photographer'], title = os.path.basename(filename), gallery_id = thegallery) + + # Try to harvest EXIF data + import EXIF + tags = EXIF.process_file(f) + if tags.has_key('Image DateTime'): + exifdate = tags['Image DateTime'].printable + photo.date = apply(datetime.date, map(int, exifdate.values.split(' ')[0].split(':'))) + if tags.has_key('EXIF UserComment'): + exiftitle = tags['EXIF UserComment'].printable + photo.title = exiftitle + + if tags.has_key('Image Orientation'): + exifrot = tags['EXIF UserComment'].printable + if exifrot = 'Rotated 90 CCW': + #DO ROTATION + continue + # Save it -- the thumbnails etc. get created. photo.save() |