wsgithumb API

WSGI Applications

wsgithumb.make_thumb_app(global_conf, document_root=None, cache_directory=None, accel_header=None, sizes={'medium': (300, 300), 'thumb': (100, 100), 'xlarge': (800, 800), 'large': (500, 500), 'small': (50, 50), 'original': None, 'icon': (16, 16)}, **settings)

thumb application factory

wsgithumb.make_file_app(global_conf, document_root=None, accel_header=None, **settings)

file application factory

Pyramid

wsgithumb.add_thumb_view(config, route_name, sizes={'medium': (300, 300), 'thumb': (100, 100), 'xlarge': (800, 800), 'large': (500, 500), 'small': (50, 50), 'original': None, 'icon': (16, 16)}, document_root=None, cache_directory=None, **view_args)

add a view to serve thumbnails in pyramid

Helpers

Serving files

While it’s not it’s primary function, wsgithumb allow to efficiently serve a file with the get_file_response() helper:

>>> from wsgithumb import get_file_response
>>> from tests import filename
>>> resp = get_file_response(filename, document_root=document_root,
...                          accel_header=None)
>>> print resp
200 OK
Content-Type: text/x-python; charset=UTF-8
Last-Modified: ... GMT
ETag: "..."
Content-Length: 114
...
wsgithumb.get_file_response(filename, document_root=None, accel_header=None)

helper the get a file response

Generating thumbnails

You want to serve images located in document_root. Use the get_image_response() helper:

>>> from wsgithumb import get_image_response
>>> from tests import document_root
>>> resp = get_image_response(document_root=document_root,
...                           cache_directory='/tmp/www/cache',
...                           size=(500, 500), path='tests/image.jpg',
...                           accel_header=None)
>>> print resp
200 OK
Content-Type: image/jpeg
Last-Modified: ... GMT
ETag: "..."
Content-Length: 23590
...

This will return a webob.Response containing a resized version of document_root/tests/image.jpg. If size is None then the file is returned without resizing.

wsgithumb.get_image_response(document_root=None, cache_directory=None, size=(500, 500), path=None, accel_header=None)

helper the get an image response

Table Of Contents

Previous topic

Welcome to wsgithumb’s documentation!