
django-photologue - issue #96
[patch] rotate images according to EXIF orientation tag
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)
- exif_rotation.patch 2.02KB
Comment #1
Posted on Jul 15, 2009 by Quick Camelis this going to be merged on trunk ?
Status: New