{ "info": { "author": "Miroslav Shubernetskiy", "author_email": "miroslav@miki725.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "Django-Multires\n===============\n\n.. image:: https://d2weczhvl823v0.cloudfront.net/miki725/django-multires/trend.png\n :alt: Bitdeli badge\n :target: https://bitdeli.com/free\n\nDjango-multires is a plug-and-play Django app for managing multiple image resolutions in a db-driven approach.\n\nWhy another lib\n---------------\n\nImages are important aspect of web development. However they come at a price of extra bandwidth due to their size which especially becomes important on mobile devices. To handle this, some sites generate multiple resolutions of each image to serve to different devices or network conditions. The usual approach in doing so is to define ahead of time terms for different levels of resolutions which will be available. For example a ``thumbnail`` could be an image up to ``200x200``, ``high-res`` be up to ``2500x2500``, etc. This is what most of the current image-management Django apps do such as `easy-thumbnails `_. In case of ``easy_thumbnails``, these presets are called aliases and some of them even allow to define more advanced options such as crop, rotation, etc. This allows for some advanced uses such as if need to generate image gallery thumbnails cropped square. That is until in one of images a face will be cropped out due to the fact that original image and gallery thumbnails are not of the same aspect ratio hence some regions need to be cropped. This results in adding a field to a model for square thumbnail image. Then of course you need the same image for the landing page banner which should be of 16x9 aspect ratio. That again cropps the image in unpleasing fashion so you end up adding another field. You can probably see where this is going.\n\nThis library does not require to hard code any rules as to how the images will be processed. All rules are stored in a database. So if a need arises to apply a special treatment to any specific image, it is just a matter of creating another rule in db on how to process that specific image. Additional advantage of this approach is that it becomes much easier to change these rules once the application is deployed (no need to change anything in ``settings.py``).\n\nOverview\n--------\n\nAs discussed in **Why another lib**, this library approaches a problem of managing multiple image resolutions in more database-driven way. Each rule how the image should be processed is represented by a ``MultiresRecipe`` model and each processed image is represented by ``MultiresImage`` model. Using them directly can be tedious however you can use a lightweight wrapper ``MultiresImageField`` around ``ImageField`` for more simple API::\n\n from multires import MultiresImageField, MultiresRecipe\n\n # a simple thumbnails recipe\n # usually would create this in Django admin\n recipe = MultiresRecipe.objects.get_or_create(\n title='thumbnail',\n description='Recipe for thumbnails',\n namespace='abc',\n width=200, height=200,\n file_type='jpeg', quality=80\n )[0]\n\n # some test data\n class FooModel(models.Model):\n image = MultiresImageField(upload_to='foo', namespace='abc')\n foo = FooModel.objects.create(image=...)\n\n # get multires image for foo's image\n image = foo.image.get_multires_image(recipe)\n\n # get lazy url for thumbnail image\n print(image.image.url)\n\n # or process it manually\n image.process()\n\n # get the url for the processed image as per MEDIA_URL\n # since image has been already processed\n print(image.image.url)\n\nInstallation\n------------\n\nSince this package is still in development, no stable version has been uploaded to PYPI yet. You can however install it as a `developer `_ version::\n\n $ pip install django-multires==dev\n\nOnce installed, add it to the ``INSTALLED_APPS``::\n\n INSTALLED_APPS = (\n ...,\n 'multires',\n ...\n )\n\nAnd then do the syncdb to create the necessary db tables::\n\n $ python manage.py syncdb\n\nAdd the multires urls to Django's root urls config to enable lazy urls::\n\n urlpatterns = patterns(\n ...\n url(r'^multires/', include('multires.urls', namespace='multires')),\n )\n\nCredits\n-------\n\nCurrent maintainers:\n\n* Miroslav Shubernetskiy - `GitHub `_\n\nLicense\n-------\n\nThe source code can be found at GitHub ``_.\n\nThis library is licensed with `MIT License `_::\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/miki725/django-multires", "keywords": "django", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-multires", "package_url": "https://pypi.org/project/django-multires/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-multires/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/miki725/django-multires" }, "release_url": "https://pypi.org/project/django-multires/0.1/", "requires_dist": null, "requires_python": null, "summary": "Django-multires is a plug-and-play Django app for managing multiple image resolutions in a db-driven approach.", "version": "0.1" }, "last_serial": 986527, "releases": { "0.1": [] }, "urls": [] }