Skip to main content

A Python web server that uses PIL 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.

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

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.

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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for thumpy-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e2db73d937f7fec438a4a41a5a801b95f6c8fea2a57fb9125d3559373d0bb733
MD5 036ff181f633a53b0906141130bc86a2
BLAKE2b-256 beb21a5601bb7bbb92106089a51d41969bc1929f9cda403953dc1f031ca3139d

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