Cubist Documentation

Cubist Documentation
Release 0.1
Jan Bednařík
July 20, 2012
CONTENTS
1
Documentation
1.1 Installation . . . . .
1.2 Processing Functions
1.3 API . . . . . . . . .
1.4 Usage Examples . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
3
4
4
i
ii
Cubist Documentation, Release 0.1
Cubist is a lightweight open source image server with image processing functions written in Python.
Main goal is to save the time with preparations and managment of many various sizes of an image. Upload
just a source image and let Cubist serve it in any required size. Simply by specifying size in image URI (e.g.
my_image.r100x50.jpg ). Cubist provides also other image processing functions than resize.
Features include:
• Supported image formats: JPEG, PNG, GIF.
• Supported Processing Functions: Resize, Fit, Crop.
• Simple API for uploading images using HTTP POST.
• Designed for use with multiple websites containing the same images.
• Solves the problem with non-unique filenames of images by using their SHA1 hash as filename and ID.
• Cache for fast serving processed images.
• Runs as standard Python WSGI application on various web servers (Apache, Nginx, ...).
CONTENTS
1
Cubist Documentation, Release 0.1
2
CONTENTS
CHAPTER
ONE
DOCUMENTATION
1.1 Installation
1.2 Processing Functions
Processing function is defined as <parameter> in the URI of image. URI format is:
<filename>.<parameter>.<extension>
Examples:
image.r100x200.jpg
nicephoto.f500x500.png
FooBar.c50x100.gif
All dimensions are in pixels.
1.2.1 Resize
Resizes image.
URI parameter:
r<width>x<height>
<width> or <height> is optional:
1. If both <width> and <height> are set then image is resized exactly to this size. It ignores image size ratio
and may deform it. Example:
image.r100x50.jpg
2. If <height> is 0 or missing then it’s calculated from <width> and it keeps image size ratio. Examples:
image.r100x.jpg
image.r100x0.jpg
3. If <width> is 0 or missing then it’s calculated from <height> and it keeps image size ratio. Examples:
image.rx50.jpg
image.r0x50.jpg
See Usage Examples for examples with images.
3
Cubist Documentation, Release 0.1
1.2.2 Fit
Fit function is usable when you don’t know if na image is landscape or portrait oriented, or you dont know exact size
ratio, and you want it to fit into available area.
URI parameter:
f<width>x<height>
Both <width> and <height> are required. They defines available area in pixels.
Example:
image.f200x200.jpg
See Usage Examples for examples with images.
1.2.3 Crop
Usual use of crop is on images with some kind of pattern which may be lost when image is resized.
URI parameter:
c<width>x<height>
Both <width> and <height> are required.
Example:
image.c100x100.jpg
See Usage Examples for examples with images.
1.3 API
1.4 Usage Examples
Here are some examples how Cubist can serve you images.
Original image:
http://cubist.example.com/pony.jpg
4
Chapter 1. Documentation
Cubist Documentation, Release 0.1
size: 300 x 200 px
1.4.1 Resize
See Processing Functions for details.
Resize to 150 x 100 px:
http://cubist.example.com/pony.r150x100.jpg
size: 150 x 100 px
Resize to 100 x 150 px:
http://cubist.example.com/pony.r100x150.jpg
size: 100 x 150 px
Resize width to 125 px (height is calculated from image size ratio):
http://cubist.example.com/pony.r125x.jpg
size: 125 x 83 px
1.4. Usage Examples
5
Cubist Documentation, Release 0.1
Resize height to 125 px (width is calculated from image size ratio):
http://cubist.example.com/pony.rx125.jpg
size: 187 x 125 px
1.4.2 Fit
See Processing Functions for details.
Fit into square 200 x 200 px:
http://cubist.example.com/pony.f200x200.jpg
size: 200 x 133 px
Fit into rectangle 300 x 100 px:
http://cubist.example.com/pony.f300x100.jpg
size: 150 x 100 px
1.4.3 Crop
See Processing Functions for details.
Crop to 150 x 100 px:
http://cubist.example.com/pony.c150x100.jpg
size: 150 x 100 px
6
Chapter 1. Documentation