django-metaimage is a GPL-licensed app for the Django web framework. Many sites deal with images/photos, which usually come from three sources: uploaded by a user, pulled from the Internet via a URL, or generated server-side. For the latter two cases, django-metaimage should be helpful: a new instance can take either a remote image URL, or raw image data as a string (e.g. as might be produced via Matplotlib).
The main MetaImage model provides a wrapper of useful functionality around ImageModel from the powerful django-photologue app (a dependency). Some of the django-metaimage code was initially inspired from Pinax's photo app, but I have removed Pinax dependencies, so that django-metaimage only requires:
You might need django-uni-form, if you want to use the included example templates, and want to see all django-metaimage's tests pass.
In sum, this app is provides more flexibility with local representation of images on your site from multiple sources, whether uploaded, from remote images, or sever-side generated images.
The main class, MetaImage, enables storing useful metadata about images, including a title, caption, notes about the source (e.g. copyrights, permissions), and tags. MetaImage attributes include:
Now, to handle the two cases of storing images that the app was made for: retrieval of a remote image from its URL (you'll have a local copy in case the image moves/disappears), or storing a server-side generated image:
new_metaimage = MetaImage( title='Django logo', source_url='http://media.djangoproject.com/img/site/hdr_logo.gif', source_note='The logo of the Django project.', creator=foo_user) new_metaimage.save() # Will download, save source_url locally.
new_metaimage = MetaImage( title='Chart of f(x)', source_note='Chart of f(x) generated by Matplotlib.', creator=foo_user) new_metaimage.save(image_data=a_png_as_str)
Useful MetaImage methods include:
Basic views, tests, and templates are also provided, so you can quickly integrate the app into an existing Django site.
Install via "pip install django-metaimage" or from source. You may also need to do pip install for django-taggit, django-autoslug, and photologue.
Then update your Django project's settings.py file: add "photologue", "taggit" and "metaimage" (autoslug does not need to be there) in the INSTALLED_APPS list, e.g.
INSTALLED_APPS = [ ... "photologue", "taggit", "metaimage", ... ]
And then, do a "manage.py syncdb" to create the database tables needed.
OPTIONAL: Templates are provided for adding, editing, viewing, etc. of metaimages; they're very basic and meant only as a starting point. But if you want to use them directly, do at least these two things:
urlpatterns = patterns("", ... (r"^metaimage/", include("metaimage.urls")), ... )
Also, many of the django-metaimage templates have templatetags dependencies that are commented out, as they require Pinax or other packages; you can activate them as needed, but be sure to update your INSTALLED_APPS accordingly.
I've included a set of unit tests for the app; if you have integrated django-metaimage into an existing Django site/project, just do the usual "manage.py test" and the tests should be run, BUT for all tests to pass, the current trunk (as of 2/2011) of django-uni-form is needed:
Should you want to run django-metaimage's test suite outside of any particular Django site/project - i.e. stand-alone Django app testing - I suggest installing and using the django-app-test-runner and my fork of it at:
...which enables usage of a testing-specific settings file. After you install django-app-test-runner in your virtualenv (don't develop in Python without it!) you should be able to do something like:
cd to/where/django-metaimage/code/is app-test-runner ./src/metaimage/ -s src/metaimage/testsettings.py
Note that you'll need Internet connectivity for the tests to pass.
Please log errors/issues using django-metaimage's github site, http://github.com/limist/django-metaimage/issues
|File||Type||Python Version||Uploaded On||Downloads|
|django_metaimage-0.4-py2.6.egg||Egg||2.6||May 21, 2011||2,436|
|django-metaimage-0.4.tar.gz||Source||May 21, 2011||2,636|
|Aug. 26, 2015, 12:17 a.m.||django-metaimage||0.4||Release Created|
|Aug. 26, 2015, 12:17 a.m.||django-metaimage||0.3||Release Created|
|Aug. 26, 2015, 12:17 a.m.||django-metaimage||Package Created|