Crop and Gravity
Control the focal point and cropping behavior of image transformations.
The g (gravity) parameter controls where the image is anchored when cropping. It works with crop, thumb, and fill resize modes.
Compass Gravity
Position the crop using cardinal directions:
| Value | Position |
|---|---|
center | Center of the image (default) |
centre | Same as center |
north | Top center |
south | Bottom center |
east | Right center |
west | Left center |
northeast | Top right |
northwest | Top left |
southeast | Bottom right |
southwest | Bottom left |
Examples
# Crop from the top
?w=800&h=400&r=crop&g=north
# Crop from the bottom-right
?w=800&h=400&r=crop&g=southeast
# Center crop (default)
?w=800&h=400&r=crop&g=center
Facial Gravity
Use face detection to position the crop around detected faces.
| Value | Behavior |
|---|---|
face | Centers crop on the largest detected face |
faces | Same as face (centers on largest) |
eyes | Face detection focused on the eye region |
auto | Intelligent positioning (currently same as face) |
Examples
# Crop around the main face
?w=400&h=400&r=crop&g=face
# Face-focused thumbnail
?w=200&h=200&r=thumb&g=face
How Face Detection Works
- The image is analyzed for face detection
- Detected faces are returned as bounding boxes
- Faces are sorted by area (largest first)
- The crop is centered on the largest face
- If no faces are detected, the crop falls back to center gravity
Face detection results are cached. Subsequent requests for the same image use cached results automatically.
Thumb Mode with Face Detection
When using r=thumb with facial gravity, Tuzzle applies smart zoom:
- Detects the face bounding box
- Applies a zoom factor (2x) around the face
- Adjusts the crop region to keep the face centered
- Resizes to the requested dimensions
This produces tighter, portrait-style thumbnails focused on the subject's face.
Gravity with Different Resize Modes
| Resize Mode | Gravity Effect |
|---|---|
fit | Gravity is ignored (no cropping occurs) |
scale | Gravity is ignored (exact resize, no cropping) |
fill | Gravity controls the anchor point for the cover crop |
crop | Gravity controls which region is extracted |
thumb | Gravity controls the focal point for smart cropping |