Skip to main content

A tile-on-demand tile server built with PIL and Tornado

Project description

projectile
==========

A tile-on-demand tile server built with PIL and Tornado.

Motivation
----------

We want to store a high-resolution image in memory on the server as a numpy
array. Then when a client requests a particular tile, we can make the PNG of the
requested tile by slicing the numpy array and using PIL to write the resulting
PNG back to the client through a StringIO stream.

Demo
----

Install projectile

$ pip install projectile

Serve a test image from the [USC-SIPI Image Database](http://sipi.usc.edu/database/):

$ projectile sanfran

Manually request a particular tile by navigating to <http://localhost:8000/2/1/2.png>.

Try zooming and panning in the demo client by navigating to <http://localhost:8000/>.

Serve one of your own images with

$ projectile some_image.tiff

or, if you have data in a numpy `.npy` file,

$ projectile some_image.npy

Dependencies
------------

- `numpy>=1.13.3`
- `Pillow>=4.3.0`
- `tornado>=4.5.2`
- `six>=1.11.0`

API
---

### Using a custom client

If you like the projectile backend but just want to use a simple custom client
contained in a single HTML file `custom_client.html`, you can run

$ projectile array.npy --client custom_client.html

to make projectile serve your client instead of the included demo client.

### Using projectile in your existing Tornado web application

The core functionality is exposed in the `TileHandler` class defined in
[server.py](projectile/server.py), which you can use in your own Tornado web
applications:

```python
from tornado import web
from projectile.server import TileHandler

...

app = web.Application([
(r'/([0-9]+)/([0-9]+)/([0-9]+).png', TileHandler, dict(array=array)),
...
])

...
```

### Launching projectile from your own Python code

You can also launch a server from your own Python code with the `run()` function
defined in [server.py](projectile/server.py):

```python
from projectile.server import run

run(array)
```

Credits
-------

The demo client is lifted from <http://bl.ocks.org/mbostock/5914438>, with the
addition of a small filtering check to prevent the client from requesting tiles
which lie beyond the image boundaries.


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

projectile-0.0.1.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

projectile-0.0.1-py2-none-any.whl (8.2 kB view details)

Uploaded Python 2

File details

Details for the file projectile-0.0.1.tar.gz.

File metadata

  • Download URL: projectile-0.0.1.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for projectile-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1e373f294829eaa4ffc3d60f3ae102828be3fe6935a061148ea0a3f973ab998d
MD5 51e44b7fbd8b2f2b50100934fcfac6e4
BLAKE2b-256 3a68efeb82e9db81f1f1d6b2589086ff98ea04c7c9a9960aae8715acfc3a8d3d

See more details on using hashes here.

File details

Details for the file projectile-0.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for projectile-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 7fd337af9b6b64f180132947e117c73fe64d19c898465617d4b71ebdcb9de633
MD5 ad40174327f701736ac0470349e7ed8d
BLAKE2b-256 a00e3cb4717a9d82a19b27f773a479de64a2c50bddcadb63fb6d0a051c52fb8d

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