diff options
author | bnewbold <bnewbold@ziggy.(none)> | 2009-08-23 00:21:48 +0300 |
---|---|---|
committer | bnewbold <bnewbold@ziggy.(none)> | 2009-08-23 00:21:48 +0300 |
commit | a22f1bea8167e77a7866353db473dfdb4a4161f3 (patch) | |
tree | c16ad8d48711d81f5c91dcf83df15b9e37e4287b /bn_django/photos | |
parent | fe70e8db7b65562bd532a1aacacb759df6f7b130 (diff) | |
download | bnewnet-a22f1bea8167e77a7866353db473dfdb4a4161f3.tar.gz bnewnet-a22f1bea8167e77a7866353db473dfdb4a4161f3.zip |
first whack at fixing bulk photo uploads
Diffstat (limited to 'bn_django/photos')
-rw-r--r-- | bn_django/photos/templates/photos/import_form.html | 3 | ||||
-rw-r--r-- | bn_django/photos/urls.py | 6 | ||||
-rw-r--r-- | bn_django/photos/views.py | 18 |
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() |