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.

This is primarily intended for building interactive visualizations in research
settings where we might want to skip the time- and/or disk-intensive tile
generation step required by typical tile servers.

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

Stress testing
--------------

To test the performance limits of on-demand tiling, download this
[high resolution map of Great Britain](https://commons.wikimedia.org/wiki/File:A_new_map_of_Great_Britain_according_to_the_newest_and_most_exact_observations_(8342715024).jpg)
(8,150 × 13,086 pixels, file size: 102.74 MB) from Wikimedia Commons.

Grayscale performance test:

$ projectile britain.jpg -m L

Reducing tile resolution when running in color:

$ projectile britain.jpg --tile_size 7

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.3.tar.gz (22.6 kB view details)

Uploaded Source

Built Distributions

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

projectile-0.0.3-py2.py3-none-any.whl (10.5 kB view details)

Uploaded Python 2Python 3

projectile-0.0.3-py2-none-any.whl (10.5 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for projectile-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bcb6fe3ab57704a557e28f2a28262809de56a27ad0e450526e2232b4945235a5
MD5 9299056323b7195f727c6a6fa5fde4a0
BLAKE2b-256 6dc20661c1745ffdd102483b242a57fa77c8c15b75f0816f51c6aee26b630fad

See more details on using hashes here.

File details

Details for the file projectile-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for projectile-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9711d58bb91947f95da82c4a5c5a2f2da4ee95a54089928f2ebe19276861648a
MD5 5eb5cc0f62488409090d020c32f1b77c
BLAKE2b-256 9880bbeb092d4d8a7e8d2cee1c6fc71ce4a2ce59bdcb81eeee162a62e5a79356

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for projectile-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 9b533380eeaea6f4e648d59c63996a6aaf5a6fe9028000d9b4e515d5c7f14d70
MD5 1641c7afce21b5e900febfa3a44101f1
BLAKE2b-256 c4307ba302aedb1bba1619365020f32d8d122135e048b8498a3784813a3f03eb

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