GET
/
transform
curl --request GET \
  --url https://api.thunderimage.com/image/transform
This response does not have an example.

Crop Operations

1. Manual Crop

Manually crop the image at specified coordinates.

Format: crop=AxB:CxD

Where:

  • A,B: Coordinates of the left-top point
  • C,D: Coordinates of the right-bottom point

Coordinates can be provided as:

  • Pixel values (e.g., 100x100:300x300)
  • Float values between 0 and 1, representing percentage of image dimensions (e.g., 0.1x0.1:0.9x0.9)

Original Image

URL : https://www.thunderimage.com/sample/yosemite.jpg

Cropped Image

URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&crop=100x100:300x300

2. Trim

Removes surrounding space in images using the top-left pixel color.

Format: trim=true

Original Image with Surrounding Space

URL : https://www.thunderimage.com/sample/yosemite-with-space.png

Trimmed Image

URL: /transform?url=https://www.thunderimage.com/sample/yosemite-with-space.png&trim=true

3. Smart Crop

Uses smart detection of focal points for cropping.

Format: smart=true&crop=widthxheight

Original Image

URL : https://www.thunderimage.com/sample/yosemite.jpg

Smart Cropped Image

URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&smart=true&crop=300x300

4. Crop Alignment

Specify the alignment for cropping operations.

Format: crop=widthxheight&halign=value&valign=value

Where:

  • HALIGN: Horizontal alignment of crop. Accepts left, right, or center (default).
  • VALIGN: Vertical alignment of crop. Accepts top, bottom, or middle (default).

Original Image

URL : https://www.thunderimage.com/sample/yosemite.jpg

Cropped Image with Right-Bottom Alignment

URL: /transform?url={URL}&crop=300x300&halign=right&valign=bottom

Best Practices

  • Use manual crop when you need precise control over the cropped area.
  • Trim is useful for removing unnecessary whitespace or backgrounds.
  • Smart crop is ideal for preserving the most important parts of an image when cropping to specific dimensions.
  • Combine crop operations with resize operations for more complex transformations.

Notes

  • When using percentage-based coordinates for manual crop, remember that they are relative to the original image dimensions.
  • The smart crop feature may not always produce the expected results for all images, so it’s best to review the output and adjust as necessary.
  • When using halign and valign with smart=true, smart cropping will take precedence. This means that if smart cropping is enabled, it will override the alignment settings to focus on the detected focal points of the image.
  • If you need specific alignment control, it’s recommended to use halign and valign without enabling smart cropping.

Query Parameters

url
string
required

The URL of the image to be transformed.

Example:

"https://www.thunderimage.com/sample/yosemite.jpg"

crop
string

Manually crop the image. Format: AxB:CxD where A,B is the top-left point and C,D is the bottom-right point.

Example:

"100x100:300x300"

trim
boolean

Remove surrounding space in images using the top-left pixel color.

Example:

true

smart
boolean

Use smart detection of focal points for cropping.

Example:

true

halign
enum<string>
default:center

Horizontal alignment for crop.

Available options:
left,
center,
right
valign
enum<string>
default:middle

Vertical alignment for crop.

Available options:
top,
middle,
bottom

Response

200
image/jpeg

The transformed image with crop operations applied.

The response is of type file.