Skip to main content

A Python web server that uses Pillow to dynamically scale, crop, transform and serve images from S3 or the local filesystem

Project description

Meet Thumpy

Thumpy is a Python web service that crops and scales images. It doesn’t store anything. It’s meant to be used as an origin server sitting behind a CDN such as Amazon CloudFront.

Configuration

Settings are stored in the settings.yaml file. They should include: - the name and access keys to your S3 bucket - compression quality (e.g. 80) - list of CORS allowed hosts

Interface

Thumpy serves images using the same paths as their storage location on S3. Conversion parameters are specified in the query string, using an interface inspired by TimThumb.

examples:

Scaling

Scale the width to 200px, and the height proportionally:

http://mythumpyserver.somewhere/castle.jpg?w=200

Scale the height to 150px, and the width propotionally:

http://mythumpyserver.somewhere/castle.jpg?w=200

Specify both height and width:

http://mythumpyserver.somewhere/castle.jpg?w=200&h=150

Scaling (Post processing)

Same as Scaling (above) but applied to the output image after all transformations

http://mythumpyserver.somewhere/castle.jpg?pw=200&ph=150

Cropping

Crop the width to 200 and the height to 100:

http://mythumpyserver.somewhere/castle.jpg?cw=200&ch=100

Crop the width and height to 50:

http://mythumpyserver.somewhere/castle.jpg?cw=50&ch=50
  • Thumpy will always scale first before any cropping.

  • Thumpy always crops from the center of the image.

Reveal Mask / Zoom Cropping

Minimum 3 parameters required: - Top offset (e.g. zct=100px) - Left offset (e.g. zcl=100px) - Width or Height of the output crop from the offsets. If only one is provided the other will automatically be assigned the other’s value.

The mask should be applied to the original image which means there is no scaling but only masking.

See: Scaling (Post processing) to get the scaled mask/crop.

Get 100px x 50px scaled crop off a larger image with a reveal mask of 350px x 175px applied at 20px x 10px top-left offset.

http://mythumpyserver.somewhere/castle.jpg?zcw=350&zch=175&zct=20&zcl=10&pw=100&ph=50

Greyscale

Example of a greyscale image with no resizing::

http://mythumpyserver.somewhere/castle.jpg?gray=1

Cloudfront Ugliness

If the “cloudfront_ugliness” option in thumpy’s config is set to true, then the image modification parameters will be pulled from the first segment of the path instead of the URL query string.

This is to workaround Amazon Cloudfront dropping the URL query string when making requests to your origin server. Example:

http://mycloudfrontdist.somewhere/w=100/path/to/image/castle.jpg

For the original, unaltered image, place an “o” where the query string would go, like this:

http://mycloudfrontdist.somewhere/o/path/to/image/castle.jpg

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

thumpy-0.3.2.tar.gz (484.3 kB view details)

Uploaded Source

Built Distributions

thumpy-0.3.2-py3-none-any.whl (483.0 kB view details)

Uploaded Python 3

thumpy-0.3.2-py2.py3-none-any.whl (483.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file thumpy-0.3.2.tar.gz.

File metadata

  • Download URL: thumpy-0.3.2.tar.gz
  • Upload date:
  • Size: 484.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for thumpy-0.3.2.tar.gz
Algorithm Hash digest
SHA256 088e3f74adacb687692c19202c60f3652e415f7e884dd42539cd20c7b75a848a
MD5 86465c7c5e325b002c710350391740a2
BLAKE2b-256 7559e5b8d5150a31c9338434250a96a305606d7e5f79f7cc9afd9440d6462ef0

See more details on using hashes here.

File details

Details for the file thumpy-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for thumpy-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 faf2cbe2cb6a906fb752a2e8528775b1144268c62a41b6e21bdfb75eafcd382a
MD5 929b068b339ec1b24d3ed3862e310490
BLAKE2b-256 3abd1ba38b3a63a971f403a16b9371b2c132bad8e4c743f8f3fd823ed039d6cb

See more details on using hashes here.

File details

Details for the file thumpy-0.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for thumpy-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3316fabbf5f62034c75d7ad42d37d11048777c84b7846b38bcd7f21c121dbdcb
MD5 3d5bd79ee31a306801a3294962e54b67
BLAKE2b-256 289dc4a37f77ec67c222f75414b6f3a86115323365976deeb365fd8db5e9e4da

See more details on using hashes here.

Supported by

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