{ "info": { "author": "Vinicius Mendes", "author_email": "vbmendes@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Multimedia :: Graphics :: Graphics Conversion", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Django Dynamic Sprites\n======================\n\nCreate sprites dynamicaly for Python and Django.\n\nVersion 0.1.3\n\nInstalation\n-----------\n\nInstall the package via ``pip``::\n\n pip install django-dynamic-sprites\n\nGenerating sprite for images in a folder\n----------------------------------------\n\nOne way to generate sprites is from all pictures within a folder. To do so, type this command::\n\n generate_sprites.py path/to/folder path/to/output\n\nOne thing to notice is that you don't pass the output extension. The script already generates the image with ``.png`` and the CSS with ``.css``.\n\nGenerating sprite from Python code\n----------------------------------\n\nWithin your python code you can generate sprites for a given set of images. All you have to do is provide the images paths, a nome to each image, generate the sprite and save it::\n\n from dynamic_sprites.sprite import Sprite\n\n images = (\n ('brazil', '/path/to/brazil/image.png'),\n ('usa', '/path/to/usa/image.png'),\n )\n\n sprite = Sprite('sprite_name', images)\n\n output_image = sprite.generate()\n output_image.save('/path/to/output/image.png')\n\n output_css = sprite.generate_css('http://images.com/output/image.png')\n output_css.save('/path/to/output/style.css')\n\nThat's the basics for generating a sprite from Python code. But there is some abstractions integrating it with Django. Even the name of the project having Django on it, the sprites can be generated without using Django.\n\nGenerating sprites for Django queryset objects\n----------------------------------------------\n\nLet's pretend you have a Django model like this::\n\n from django.db import models\n\n class Country(models.Model):\n name = models.CharField(max_length=255)\n slug = models.SlugField()\n flag = models.ImageField(upload_to='countries')\n\nAnd you want to have a sprite with all the country flags. You can generate it using a ``Sprite`` specialization::\n\n from dynamic_sprites.model_sprite import ModelSprite\n\n sprite = ModelSprite('country-flags', queryset=Country.objects.all(), image_field='flag', slug_field='slug')\n\n output_image = sprite.generate()\n output_image.save('/path/to/output/image.png')\n\n output_css = sprite.generate_css('http://images.com/output/image.png')\n output_css.save('/path/to/output/style.css')\n\nYou can also connect the sprite generation to the post_save listener and have your sprite generated again each time an object in your queryset is saved::\n\n from django.db.models.signals import post_save\n from dynamic_sprites.listeners import ModelSpriteListener\n\n listener = ModelSpriteListener('country-flags', image_field='flag', slug_field='slug', queryset=Country.objects.all())\n\n post_save.connect(listener, sender=Country)\n\nContributing to the project\n---------------------------\n\nThis project is open source, contributions are welcome.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/vbmendes/django-dynamic-sprites/downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vbmendes/django-dynamic-sprites", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-dynamic-sprites", "package_url": "https://pypi.org/project/django-dynamic-sprites/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-dynamic-sprites/", "project_urls": { "Download": "https://github.com/vbmendes/django-dynamic-sprites/downloads", "Homepage": "https://github.com/vbmendes/django-dynamic-sprites" }, "release_url": "https://pypi.org/project/django-dynamic-sprites/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "A way to generate sprites based on objects created by the application user.", "version": "0.1.3" }, "last_serial": 789519, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "995309a7c257a5786757e6e963766e95", "sha256": "e802e1fe681f0e4a66712515415a028866728d54b1de9c6be1b9528f3d5fbbca" }, "downloads": -1, "filename": "django-dynamic-sprites-0.1.3.tar.gz", "has_sig": false, "md5_digest": "995309a7c257a5786757e6e963766e95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11773, "upload_time": "2012-05-04T04:43:29", "url": "https://files.pythonhosted.org/packages/e5/90/d98ff70cd1785987cb30bf05bc41f501c25603b97649f5cd23e0e226a3a8/django-dynamic-sprites-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "995309a7c257a5786757e6e963766e95", "sha256": "e802e1fe681f0e4a66712515415a028866728d54b1de9c6be1b9528f3d5fbbca" }, "downloads": -1, "filename": "django-dynamic-sprites-0.1.3.tar.gz", "has_sig": false, "md5_digest": "995309a7c257a5786757e6e963766e95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11773, "upload_time": "2012-05-04T04:43:29", "url": "https://files.pythonhosted.org/packages/e5/90/d98ff70cd1785987cb30bf05bc41f501c25603b97649f5cd23e0e226a3a8/django-dynamic-sprites-0.1.3.tar.gz" } ] }