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
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::
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file thumpy-0.4.3.tar.gz
.
File metadata
- Download URL: thumpy-0.4.3.tar.gz
- Upload date:
- Size: 484.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3853e6ea9e876e36e1979443c181a78f221c22aef4ed039d8f906239bd717f85 |
|
MD5 | a9f3d6d6cf029b462c8d1227e78e2977 |
|
BLAKE2b-256 | 53ce85f75f462c850e78a2de334edc6ad15515e3bd7a9b5071480bf9a73b8768 |