Skip to main content

A simple Django app to create deep zoom tiled images. Now with OpenSeaDragon control. Python 2/3, Django 1.4+, Pillow 1.7.8+ compatible.

Project description

Django-deepzoom is a drop-in Django app for the creation and use of Deep Zoom tiled images. It handily integrates Daniel Gasienica’s and Kapil Thangavelu’s deepzoom.py image generator and the OpenSeadragon deep zoom viewer into a set of model classes and template tags which programmatically generate tiled images and all JavaScript necessary for their instantiation into templates.

Detailed documentation is available on ReadTheDocs.

Author:

David J Cox

Contact:

<davidjcox.at@gmail.com>

Version:

2.0

Let me know what you think of it…

What’s New?

Django-deepzoom 2.0 is a new unified version! It’s now compatible with both Python 2 and Python 3, all versions of Django from 1.4 onward, and with Pillow 1.7.8 onward. Now it’s truly drop-in ready… The OpenSeadragon open source deep zoom viewer has replaced the Microsoft Seadragon control. The project benefits from a truly open solution free from dependencies. The deepzoom generator parameters have been changed from a arg list to a kwarg dictionary to make things easier. More robust input checking and better exception handling have also been added.

Run tests

After django-deepzoom has been installed, you may want to sanity check it by running tests, like this:

python manage.py test deepzoom --settings=deepzoom.test.test_settings

Quick start

1.) Install “django-deepzoom” like this:

pip install -U django-deepzoom

or, like this:

wget https://pypi.python.org/packages/source/d/django-deepzoom/django-deepzoom-2.0.tar.gz
tar -xvf django-deepzoom-2.0.tar.gz
cd django-deepzoom-2.0
python setup.py install

2.) Add “deepzoom” to your INSTALLED_APPS setting like this:

(in settings.py)

INSTALLED_APPS = (
    ...
    'deepzoom',
    ...
)

3.) Sub-class the ‘UploadedImage’ model class as your own (image-based) class, something like this:

(in models.py)

from deepzoom.models import DeepZoom, UploadedImage
    from django.contrib import admin

class MyImage(UploadedImage):
            '''
            Overrides UploadedImage base class.
            '''
            pass

    admin.site.register(MyImage)

4.) Run python manage.py syncdb to create the django-deepzoom models.

5.) Add an appropriate URL to your Urlconf, something like this:

(in urls.py)

from deepzoom.views import deepzoom_view

urlpatterns = patterns('',
    ...
    url(r'^deepzoom/(?P<passed_slug>\b[a-z0-9\-]+\b)',
        deepzoom_view,
        name="v_deepzoom"),
    ...
)

6.) Write a view that queries for a specific DeepZoom object and passes it to a template, something like this:

(in views.py)

from deepzoom.models import DeepZoom

def deepzoom_view(request, passed_slug=None):
  try:
      _deepzoom_obj = DeepZoom.objects.get(slug=passed_slug)
  except DeepZoom.DoesNotExist:
      raise Http404
  return render_to_response('deepzoom.html',
                            {'deepzoom_obj': _deepzoom_obj},
                            context_instance=RequestContext(request))

7.) In your template, create an empty div with a unique ID. Load the deepzoom tags and pass the deepzoom object and deepzoom div ID to the template tag in the body like this:

(in e.g. deepzoom.html)

{% extends "base.html" %}

{% load deepzoom_tags %}

<div id="deepzoom_div" style="width: 1024px; height: 768px;"></div>

{% deepzoom_js deepzoom_obj "deepzoom_div" %}

8.) Run python manage.py collectstatic to collect your static files into STATIC_ROOT, specifically so that the OpenSeaDragon files are available.

9.) Start the development server and visit http://127.0.0.1:8000/admin/ to upload an image to the associated model (you’ll need the Admin app enabled). Be sure to check the Generate deep zoom? checkbox for that image before saving it.

10.) Navigate to the page containing the deep zoom image and either click/touch it or click/touch the overlaid controls to zoom into and out of the tiled image.

Behold! A deeply zoomable image!

.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-deepzoom-2.0.tar.gz (564.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_deepzoom-2.0-py3-none-any.whl (519.0 kB view details)

Uploaded Python 3

File details

Details for the file django-deepzoom-2.0.tar.gz.

File metadata

  • Download URL: django-deepzoom-2.0.tar.gz
  • Upload date:
  • Size: 564.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-deepzoom-2.0.tar.gz
Algorithm Hash digest
SHA256 33dc15f6e55526f713fe5a52416e3211581d5e64ca7ee88e213cb065b677419d
MD5 334b3af3efe06eb569adc0ed9bdfd52b
BLAKE2b-256 5dba30ef16a3a6f8ad2ab352b1a7bae19199d172195fc979fe175a66328296fc

See more details on using hashes here.

File details

Details for the file django_deepzoom-2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_deepzoom-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3470bc5311abc5ae67aeabd81f0fa765ab48bcdb83c709f4b587fc6e445e3ae
MD5 5f3b0687872a60e8e20050d851776536
BLAKE2b-256 fa2005b618250dcca149ec5f46eda358f2f83cf8a14310562912f1967b84b245

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page