{ "info": { "author": "abidibo", "author_email": "abidibo@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.5", "Topic :: Software Development", "Topic :: Software Development :: User Interfaces" ], "description": "# django-subject-imagefield\n\nThis package provides a `SubjectImageField` model field which inherits from the core `ImageField` and adds support for subject position.\nThe position coordiantes are stored inside another model field defined as an option (as it occurs with the width and height optional ImageField parameters).\nA custom form field and widgets are used in order to allow the user to easily set the image subject dragging a pin over an image preview.\nSome convenience properties are added to the `attr_class` of the field in order to access the subject position coordinates in a template.\n\nUse it together with some sort of thumbs generator application in order to show always the relevan part of an image, I find it playing well with [sorl-thumbnail](https://github.com/jazzband/sorl-thumbnail).\n\n\n\nTested for django >= 1.11\n\n## Installation\n\nInstall with pip\n\n $ pip install django-subject-imagefield\n\nAdd it to your installed apps:\n\n INSTALLED_APPS = {\n #...\n subject_imagefield,\n }\n\n## Configuration\n\nYou can set the image preview width for the widget:\n\n SUBJECT_IMAGEFIELD = {\n 'PREVIEW_WIDTH': 500\n }\n\nValue is considered as number of pixels, default: 300.\n\n## Usage\n\nIn you models:\n\n from subject_imagefield.fields import SubjectImageField\n\n class MyModel(models.Model):\n image = SubjectImageField('image', upload_to='pages/img', subject_location_field='subject_location')\n subject_location = models.CharField('subject coords', max_length=7)\n\nIn a django template you've access to the following properties:\n\n- __subject_perc_position__: a dictionary containing the subject position in percentage coordinates, i.e: `{'x': 15, 'y': 37}`\n- __subject_position__: a dictionary containing the subject position coordinates in px relative to the original image dimensions, i.e: `{'x': 700, 'y': 345}`\n- __sorl__: a shortcut to get a string used as cropping paramenter for sorl-thumbnail templatetag, i.e: `'15% 37%'`\n\nExample:\n\n {% load sorl_thumbnail %}\n\n
Perc. subject position: {{ object.image.subject_perc_position }}
\nOriginal dimensions subject position: {{ object.image.subject_position }}
\nThumb cropped considering subject position:
\n {% thumbnail object.image \"200x800\" crop=object.image.sorl as thumb %}\n