aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django')
-rw-r--r--bn_django/photos/templates/photos/import_form.html3
-rw-r--r--bn_django/photos/urls.py6
-rw-r--r--bn_django/photos/views.py18
3 files changed, 24 insertions, 3 deletions
diff --git a/bn_django/photos/templates/photos/import_form.html b/bn_django/photos/templates/photos/import_form.html
index 0d4f19e..bd01a9a 100644
--- a/bn_django/photos/templates/photos/import_form.html
+++ b/bn_django/photos/templates/photos/import_form.html
@@ -51,6 +51,9 @@
you can change any of these settings on a per-photo basis
<em>after</em> you upload the images.
</p>
+<p>
+ <b>UPDATE:</b> The title and rotation will be guessed from EXIF data...
+</p>
{% else %}
<p>Oops! No gallery here!</p>
diff --git a/bn_django/photos/urls.py b/bn_django/photos/urls.py
index f50a97b..e9839b1 100644
--- a/bn_django/photos/urls.py
+++ b/bn_django/photos/urls.py
@@ -17,7 +17,7 @@ urlpatterns = patterns('django.views.generic.list_detail',
(r'^detail/(?P<object_id>\d+)/$', 'object_detail',
dict(info_dict, queryset=Photo.objects.all())),
)
-#urlpatterns += patterns('bn_django.photos.views',
- #(r'^import/(\d+)/$', 'import_photos'),
+urlpatterns += patterns('bn_django.photos.views',
+ (r'^import/(\d+)/$', 'import_photos'),
#(r'^export/(\d+)/$', 'export'),
-#)
+)
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()