{ "info": { "author": "dreipol", "author_email": "dev@dreipol.ch", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n# \ud83d\udc41 Retina\n\nRetina takes an image and a thumbnail alias and generates a dict with resized images. So if your `easy_thumbnails`\nalias looks something like this `'portrait': {'size': (150, 200)}` you'll get the resized version of the original image\nplus a retina version of it.\n\n```python \nimage = File(user.profile_image).srcset('portrait')\n\n# image holds now the following dict:\n{\n 'urls': {\n 'default': [\n 'path/to/images/profile_image__150x200.jpg',\n 'path/to/images/profile_image__300x400.jpg',\n ]\n },\n 'alt': 'John Doe',\n}\n```\n\n## Installation \nFirst, install the latest release:\n\n $ pip install retina\n\nRegister the adapters you want to use somewhere at boot:\n\n```python \nfrom filer.models import Image as FilerImage\nfrom filer.models import File as FilerFile\n\nfrom retina.adapters.filer import FilerImageAdapter, FilerFileAdapter\nfrom retina import manager\n\nmanager.update_adapters({\n FilerImage: FilerImageAdapter,\n FilerFile: FilerFileAdapter,\n})\n```\n\nOr if you're using `django` with `django-filer` (which is the use-case Retina was developed for) this is even easier:\n\n```python \nfrom retina import manager\n\nmanager.load_default_adapters()\n```\n\n## Usage\n\nInitiate the `retina.File` class with a `django-filer` `File` or `Image` model and call the `srcset` method with a `easy_thumbnails` alias as parameter on it. This will always return a dict with a `urls` and `alt` key. Where `urls` is again a dict of different sizes (`default` being the default if nothing else specified) and `alt` is just a string containing the alt text for the image. Retina tries to get the alt text by accessing any of the following properties on the `filer.Image` model: `default_alt_text`, `name`, `original_filename`\n\n### Basic\n\n```python \nimage = File(user.profile_image).srcset('portrait')\n\n{\n 'urls': {\n 'default': [\n 'path/to/images/profile_image__150x200.jpg',\n 'path/to/images/profile_image__300x400.jpg',\n ]\n },\n 'alt': 'John Doe',\n}\n```\n\n### Density\nYou can chain an additional density method to get a @3, @4, e.t.c version of the source image.\n\n```python \nimage = File(user.profile_image).density(3).srcset('portrait')\n\n{\n 'urls': {\n 'default': [\n 'path/to/images/profile_image__150x200.jpg',\n 'path/to/images/profile_image__300x400.jpg',\n 'path/to/images/profile_image__450x600.jpg',\n ]\n },\n 'alt': 'John Doe',\n}\n```\n\n### Sizes\nIf you're website needs different image dimensions, say on mobile than on desktop, you can do that as well:\n\n```python \nTHUMBNAIL_ALIASES = {\n '': {\n 'portrait_sm': {'size': (100, 100)},\n 'portrait_xl': {'size': (150, 200)},\n }\n},\n\nimage = File(user.profile_image).srcset('portrait', ['sm', 'xl'])\n\n{\n 'urls': {\n 'sm': [\n 'path/to/images/profile_image__100x100.jpg',\n 'path/to/images/profile_image__200x200.jpg',\n ],\n 'xl': [\n 'path/to/images/profile_image__150x200.jpg',\n 'path/to/images/profile_image__300x400.jpg',\n ]\n },\n 'alt': 'John Doe',\n}\n```\n\nNotice how the alias is now a combination of `portrait` + `_` + `[size]`\n\n### Additional Data\nPass in any arbitary additional data to the returned dict:\n\n```python \nimage = File(user.profile_image)).additional(foo='bar', bar='baz').srcset('portrait')\n\n{\n 'urls': {\n 'default': [\n 'path/to/images/profile_image__150x200.jpg',\n 'path/to/images/profile_image__300x400.jpg',\n ],\n },\n 'foo': 'bar',\n 'bar': 'baz',\n 'alt': 'John Doe',\n}\n```\n\nNotice how the alias is now a combination of `portrait` + `_` + `[size]`\n\n\n## Adapters\nRetina uses the concept of adapters. Each adapter implements a set of methods that define how an image instance (whatever it may be) should be resized. Retina ships with two adapters out of the box: `FilerImageAdapter` and `FilerFileAdapter`. This means, that if you followed the installation steps above you can pass in any `django-filer` `File` or `Image` model and it will output you resized versions of given file (if resizable at all). \n\nYou're free two write your own adapters and register them on the manager via the `update_adapters` method. Just pass in a dict where the key is a python `type` (like str, dict or any other object) and the value is your adapter.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dreipol/retina", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "retina", "package_url": "https://pypi.org/project/retina/", "platform": "", "project_url": "https://pypi.org/project/retina/", "project_urls": { "Homepage": "https://github.com/dreipol/retina" }, "release_url": "https://pypi.org/project/retina/0.0.2/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "Painless retina image handling", "version": "0.0.2" }, "last_serial": 4461898, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "ea29c1a9cc4cab77485a7419526b1690", "sha256": "757f58b3b100cc53bd69befdf87212cbfcead4f01124371b1ca61a27fdf34705" }, "downloads": -1, "filename": "retina-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ea29c1a9cc4cab77485a7419526b1690", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 6418, "upload_time": "2018-11-06T16:48:06", "url": "https://files.pythonhosted.org/packages/13/80/035ea13dd9333770fa754c14fe92956534ea622e50c1e71aeff137a02fef/retina-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "96623a3775887aa808fa456328b79414", "sha256": "8ef6babc55636a03b9bfb86f71b0a79c5fde0df017cec54a071271d925c8293b" }, "downloads": -1, "filename": "retina-0.0.1.tar.gz", "has_sig": false, "md5_digest": "96623a3775887aa808fa456328b79414", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 6197, "upload_time": "2018-11-06T16:48:10", "url": "https://files.pythonhosted.org/packages/6c/c5/54b314446816efc302fc7f94fc46950eb7ecc0d16912d06a4cb86b6b2222/retina-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "90c711f8e2683b3fb578dcba415a97f9", "sha256": "17c26c76f7fd7873a0ad0532f0c25cdb93ef78e88841ccc933248491e005f1a0" }, "downloads": -1, "filename": "retina-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "90c711f8e2683b3fb578dcba415a97f9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 8019, "upload_time": "2018-11-07T15:06:20", "url": "https://files.pythonhosted.org/packages/f7/18/4f9616944721baed2854cd05b683f548f1919f3233a8dbfcbca1d900bbc5/retina-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "711bd9994701180cc2f06dd925850c96", "sha256": "ad3db7500e2336a63c7e2510b30f15c4e642d33835d2afbc250525c4da96d9ea" }, "downloads": -1, "filename": "retina-0.0.2.tar.gz", "has_sig": false, "md5_digest": "711bd9994701180cc2f06dd925850c96", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 8260, "upload_time": "2018-11-07T15:06:21", "url": "https://files.pythonhosted.org/packages/1c/e9/53e0ecc3458027b7b679a05afb37208ad6470e0178d7a80b8aa80d43639c/retina-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "90c711f8e2683b3fb578dcba415a97f9", "sha256": "17c26c76f7fd7873a0ad0532f0c25cdb93ef78e88841ccc933248491e005f1a0" }, "downloads": -1, "filename": "retina-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "90c711f8e2683b3fb578dcba415a97f9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 8019, "upload_time": "2018-11-07T15:06:20", "url": "https://files.pythonhosted.org/packages/f7/18/4f9616944721baed2854cd05b683f548f1919f3233a8dbfcbca1d900bbc5/retina-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "711bd9994701180cc2f06dd925850c96", "sha256": "ad3db7500e2336a63c7e2510b30f15c4e642d33835d2afbc250525c4da96d9ea" }, "downloads": -1, "filename": "retina-0.0.2.tar.gz", "has_sig": false, "md5_digest": "711bd9994701180cc2f06dd925850c96", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 8260, "upload_time": "2018-11-07T15:06:21", "url": "https://files.pythonhosted.org/packages/1c/e9/53e0ecc3458027b7b679a05afb37208ad6470e0178d7a80b8aa80d43639c/retina-0.0.2.tar.gz" } ] }