google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[patch] rotate images according to EXIF orientation tag #96

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch will add an "orientation" field to ImageModel, as well
as autodetection from EXIF on saving/uploading (see
http://www.impulseadventure.com/photo/exif-orientation.html for a
description of the EXIF orientation tag).

If applied to already existing databases, one must execute the following
command after applying the patch, to update the database (unfortunately
Django does not support migrations yet):

 ./manage.py dbshell

Then, at the command shell, enter

 alter table photologue_photo add column orientation integer null;

To have all images auto-rotated one could execute the following command:

 ./manage.py shell

then, at the python prompt

 from photologue.models import Photo
 for photo in Photo.objects.all(): photo.save()

Note: Whether to have a separate field for orientation or use the existing
transpose mechanism via PhotoEffect may be a matter of discussion, however
I believe the following arguments speak in favor of the separate field:

a.) Rotation is almost always applied to invididual images, not sets of
images (e.g. Gallery, Size). Since only one effect is possible at image
level, it would not be possible to have other effects with these images

b.) Having to deliver 3 additional effects ("Rotate90", "Rotate180", ...)
just to make EXIF orientation processing possible does not seem to make
much sense to me

c.) IMO, displaying rotated images correctly is not really an "Effect", but
rather a feature of its own; additionally a user can easily set orientation
manually if there is no EXIF tag present (e.g. older/cheap camera without
rotation sensor)

Original issue reported on code.google.com by chris.vigelius on 4 Jan 2009 at 10:52

Attachments:

GoogleCodeExporter commented 9 years ago
is this going to be merged on trunk ?

Original comment by vinil...@gmail.com on 15 Jul 2009 at 3:18