diff options
| author | Bryan Newbold <bnewbold@animus.robocracy.org> | 2009-08-22 14:25:53 -0700 | 
|---|---|---|
| committer | Bryan Newbold <bnewbold@animus.robocracy.org> | 2009-08-22 14:25:53 -0700 | 
| commit | 51f101e077dbc2c9b92f2a56ece4be569759752f (patch) | |
| tree | dca6e3c7c22f63ff4edd1fce4ed04e808e308a5a /bn_django | |
| parent | 294f92bfd6c81fd9c134ae20cbceb73f1467ab6b (diff) | |
| parent | a22f1bea8167e77a7866353db473dfdb4a4161f3 (diff) | |
| download | bnewnet-51f101e077dbc2c9b92f2a56ece4be569759752f.tar.gz bnewnet-51f101e077dbc2c9b92f2a56ece4be569759752f.zip | |
Merge branch 'master' of /srv/git/bnewnet
Diffstat (limited to 'bn_django')
| -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() | 
