{ "info": { "author": "Vincent Agnano", "author_email": "vincent.agnano@scopyleft.fr", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 3.3", "Topic :: Utilities" ], "description": "# Django Image Fit - Resize an image on the fly\n\n[![Build Status](https://api.travis-ci.org/vinyll/django-imagefit.png)](http://travis-ci.org/vinyll/django-imagefit)\n\nImagefit allows you to render an image in a template and specify its dimensions.\nIt preserves the original image file.\n\nIt is compatible with various sources of images such as django-filebrowser's\nFileBrowseField, user uploaded images, static images, \u2026\n\nWorks on Python 3.x and Python 2.6 or more; Django 1.4 > 2.0.\n\n\n#### Benefits\n\n* only 1 image file exists on the server, therefore it's always easy to replace\nand adapt the image per template or zone.\n* no model to adapt for large image and thumbnail that may vary when redesigning\nthe website.\n* perfect match with mediaqueries to adapt on mobile, tablets and\nmulti-size screens.\n* better quality than html/css resizing and no large file download, great for\nlower bandwidth.\n\n\n#### Quick tour\n\nExample 1: render _/static/myimage.png_ image at a maximum size of 200 x 150 px:\n\n```html\n{{ \"/static/myimage.png\"|resize:\"200x150\" }}\n```\n\nExample 2: render model's _news.image_ as a thumbnail:\n\n```html\n{{ news.image|resize:\"thumbnail\" }}\n```\n\nExample 1: render _/static/myimage.png_ image at a maximum cropped size of 150 x 150 px:\n\n```html\n{{ \"/static/myimage.png\"|resize:\"150x150,C\" }}\n```\n\n#### What this is not\n\n* For creating specific model fields that resize image when model saves, see\n[django-imagekit](https://github.com/matthewwithanm/django-imagekit)\n* If you wish to avoid very large image on the server, consider resizing your original image\nbefore uploading it\n\n\n## Installation\n\n#### Download\n\nVia pip ![latest version](https://img.shields.io/pypi/v/django-imagefit.svg)\n\n```bash\npip install django-imagefit\n```\n\nor the bleeding edge version\n\n```\npip install -e git+https://github.com/vinyll/django-imagefit.git#egg=django-imagefit\n```\n\n#### update INSTALLED_APPS\n\nIn _settings.py_, add _imagefit_ in your INSTALLED_APPS\n\n```python\nINSTALLED_APPS = (\n \u2026,\n 'imagefit',\n)\n```\n\nAnd add the path relative to your project (see _configuration_ below)\n\n```python\nIMAGEFIT_ROOT = \"public\"\n```\n\n#### urls.py\n\nImagefit is a resize service, therefore include its urls.\n\nPrefix it with whatever you want (here \"imagefit\" for example):\n\n```python\nurlpatterns = urlpatterns('',\n \u2026\n url(r'^imagefit/', include('imagefit.urls')),\n)\n```\n\nCongratulations, you're all set!\n\n\n## Usage\n\nyour_template.html\n\n```html\n{% load imagefit %}\n\n\n\n\n```\n\nThis will display your _/static/image.png_:\n\n1. in the _thumbnail_ format (80 x 80 px)\n2. resized in a custom 320 x 240 pixels\n3. resized and cropped in a custom 320 x 240 pixels\n\n> the _,C_ modifier stands for _Cropping_\n\n## Configuration\n\n#### Root path\n\nYou should most probably customize the path to the root folder of your images.\nThe url your specify in your model will be concatenated to this IMAGEFIT_ROOT\nto find the appropriate image on your system.\n\nThe path will be relative to the project folder.\n\nIf starting with a \"/\", it will be an absolute path (quid about Windows).\n\n```python\nIMAGEFIT_ROOT = \"public\"\n```\n\nSo with this example the image url \"/static/image.png\" would be pointing to\n_/PATH/TO/YOUR/PROJECT/**public/static/image.png**_\n\n#### Templatetags\n\n resize(value, size) # path is relative to you settings.IMAGE_ROOT\n static_resize(value, size) # path is relative to you settings.STATIC_ROOT\n media_resize(value, size) # path is relative to you settings.MEDIA_ROOT\n\nCan be used in templates as so :\n\n {{ \"/static/logo.png\"|resize:'320x240' }}\n {{ \"logo.png\"|static_resize:'320x240' }}\n {{ \"user_avatar.png\"|media_resize:'320x240' }}\n\n\n#### Presets\n\nPresets are configuration names that hold width and height (and maybe more later on).\nImagefit is already shipped with 3 presets : _thumbnail_ (80x80), _medium_ (320x240)\nand _original_ (no resizing).\n\nYou may override them or create new ones through settings.py\n\n\nCustom presets examples :\n\n```python\nIMAGEFIT_PRESETS = {\n 'thumbnail': {'width': 64, 'height': 64, 'crop': True},\n 'my_preset1': {'width': 300, 'height': 220},\n 'my_preset2': {'width': 100},\n}\n```\n\n\n#### Cache\n\nBecause resizing an image on the fly is a big process, django cache is enabled\nby default.\n\nTherefore you are strongly invited to set your imagefit cache preferences to\nFalse for local development.\n\nYou can customize the default cache preferences by overriding default values\ndescribed below via settings.py :\n\n```python\n# enable/disable server cache\nIMAGEFIT_CACHE_ENABLED = True\n# set the cache name specific to imagefit with the cache dict\nIMAGEFIT_CACHE_BACKEND_NAME = 'imagefit'\nCACHES = {\n 'imagefit': {\n 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',\n 'LOCATION': os.path.join(tempfile.gettempdir(), 'django_imagefit')\n }\n }\n```\n\nNote that `CACHES` default values will be merge with yours from _settings.py_\n\n\n#### Formats\n\nImagefit uses PIL to resize and crop the images and this library requires to\nspecify the format of the output file. Imagefit allows you to specify an output\nformat depending of the output filename. Please note that the the output extension\nis left unchanged.\n\nYou can customize the default mapping by overriding default values described below\nvia settings.py :\n\n```python\n# Example extension -> format.\nIMAGEFIT_EXT_TO_FORMAT = {'.jpg': 'jpeg', '.bmp': 'png'}\n# Disallow the fall-back to a default format: Raise an exception in such case.\nIMAGEFIT_EXT_TO_FORMAT_DEFAULT = None\n```\n\n\n#### Expires Header\n\nDjango Imagefit comes with Expires header to tell the browser whether it should request the resource from the server or use the cached version. \nThis has two core benefits. The browser will be using the cached version of the resource in the second load and page load will be much faster. Also, it will require fewer requests to the server.\n\nAs a page score parameter, static resources used in a web page should be containing an Expires information for better performance.\n\nThe default value of the expires header is set to 30 days from now. You can override this value via settings.py as:\n\n```python\nIMAGEFIT_EXPIRE_HEADER = 3600 # for 1 hour\n```\n\n## Troubleshooting\n\n\n### \"decoder jpeg not available\" on Mac OSX\n\n\nYou may have installed PIL through pip or easy_install that\ndoes not install libjpeg dependency.\n\nIf so :\n\n1. Uninstall pil via pip\n2. Install pip via homebrew: `brew install pil`\n3. Reinstall pil via pip: `pip install pil`\n\n\n## Todo\n\n* Refactor _views.resize_\n* Make resize quality/speed configurable\n* More examples for doc\n* enable URL images in addition to system files\n\n\n## Imagefit Developers\n\n_Aka note to self_: Deploy to pypi using `make deploy`.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/vinyll/django-imagefit", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-imagefit", "package_url": "https://pypi.org/project/django-imagefit/", "platform": "", "project_url": "https://pypi.org/project/django-imagefit/", "project_urls": { "Homepage": "http://github.com/vinyll/django-imagefit" }, "release_url": "https://pypi.org/project/django-imagefit/0.6.2/", "requires_dist": null, "requires_python": "", "summary": "Render an optimized version of your original image on display. Ability to resize and crop.", "version": "0.6.2" }, "last_serial": 3698336, "releases": { "0.4": [ { "comment_text": "", "digests": { "md5": "b01263734acf0ed456bd7c7f730a6325", "sha256": "ebd5b523096984955255fbe82f3a91c932764f4e4e7edbaa94ffddd1ec03ae5c" }, "downloads": -1, "filename": "django-imagefit-0.4.tar.gz", "has_sig": false, "md5_digest": "b01263734acf0ed456bd7c7f730a6325", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7154, "upload_time": "2013-08-07T09:58:57", "url": "https://files.pythonhosted.org/packages/c9/80/f06faa3282023c8774a0f304d21a78a8deeead1f26d4b37dde91d942a970/django-imagefit-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "b83c48a98065c247340194249786cde9", "sha256": "9d0e99d101653603a109845510da6340a9b74fd10055ddce5b78327bad24d38e" }, "downloads": -1, "filename": "django-imagefit-0.5.tar.gz", "has_sig": false, "md5_digest": "b83c48a98065c247340194249786cde9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8140, "upload_time": "2017-03-23T07:50:53", "url": "https://files.pythonhosted.org/packages/16/c3/1107707f34c306a81c10b6aa261544a58db659df2ce7ec06e12cce4b0cb7/django-imagefit-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "441e198f415be50e82e53b9dc1719a64", "sha256": "a3dccc15f506409dda568c609de3e86a45864ba77b2316aa0b7b1551f5f37045" }, "downloads": -1, "filename": "django-imagefit-0.6.tar.gz", "has_sig": false, "md5_digest": "441e198f415be50e82e53b9dc1719a64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8534, "upload_time": "2018-03-19T03:35:27", "url": "https://files.pythonhosted.org/packages/51/cc/23bbc6965455e890bdeb315d527f80fdfc7a2f48184918b2431e3e40f820/django-imagefit-0.6.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "cca1d81cb4bfc17c83d8fbffbe23ae42", "sha256": "e074feb5b1a75226050b4dd12a1887f7d7c2e6c40defd41459208291f9e6393e" }, "downloads": -1, "filename": "django-imagefit-0.6.1.tar.gz", "has_sig": false, "md5_digest": "cca1d81cb4bfc17c83d8fbffbe23ae42", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8561, "upload_time": "2018-03-20T05:42:24", "url": "https://files.pythonhosted.org/packages/56/f5/8b2d4db1f2f8bbdde4adcc12235296b196b32c41d3afcdb6473df14f54cf/django-imagefit-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "fada0f5931cb363ed17ebcca4f7328e9", "sha256": "de95f706f7c2fdb4f23182d837719be9b3bb3f70d8163feba1c41db93669686e" }, "downloads": -1, "filename": "django-imagefit-0.6.2.tar.gz", "has_sig": false, "md5_digest": "fada0f5931cb363ed17ebcca4f7328e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8606, "upload_time": "2018-03-22T19:25:36", "url": "https://files.pythonhosted.org/packages/77/f3/98a37039d6d8a5814193a8928fe9276695c536f9603d038b48711efb9beb/django-imagefit-0.6.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fada0f5931cb363ed17ebcca4f7328e9", "sha256": "de95f706f7c2fdb4f23182d837719be9b3bb3f70d8163feba1c41db93669686e" }, "downloads": -1, "filename": "django-imagefit-0.6.2.tar.gz", "has_sig": false, "md5_digest": "fada0f5931cb363ed17ebcca4f7328e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8606, "upload_time": "2018-03-22T19:25:36", "url": "https://files.pythonhosted.org/packages/77/f3/98a37039d6d8a5814193a8928fe9276695c536f9603d038b48711efb9beb/django-imagefit-0.6.2.tar.gz" } ] }