Resize Operations
Various resize operations for image transformation
Resize Operations
1. Basic Resize
Resize the image to specific dimensions.
Format:
w=width&h=height
Where:
- width: Desired width of the image
- height: Desired height of the image
Example: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=300&h=200
Original Image
URL : https://www.thunderimage.com/sample/yosemite.jpg
Resized Image
URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=300&h=200
2. Fit-In
Resizes the image to fit within specified dimensions without cropping. The image retains its aspect ratio.
Format:
fit_in=true&w=width&h=height
Where:
- width: Width of the imaginary box
- height: Height of the imaginary box
Example: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&fit_in=true&w=300&h=200
Original Image
URL : https://www.thunderimage.com/sample/yosemite.jpg
Fit-In Resized Image
URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&fit_in=true&w=300&h=200
3. Stretch
Resize the image to exact dimensions without keeping its aspect ratio.
Format:
w=width&h=height&stretch=true
Where:
- width: Desired width of the image
- height: Desired height of the image
Example: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=300&h=200&stretch=true
Original Image
URL : https://www.thunderimage.com/sample/yosemite.jpg
Stretched Image
URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=300&h=200&stretch=true
4. Flip
Flip the image horizontally, vertically, or both by using negative values for width and/or height.
Format:
w=width&h=height
Where:
- width: Positive for normal, negative for horizontal flip
- height: Positive for normal, negative for vertical flip
Example: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=-300&h=-200
Original Image
URL : https://www.thunderimage.com/sample/yosemite.jpg
Flipped Image
URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&w=-300&h=-200
5. Padding
Add padding to the image.
Format:
padding=GxH:IxJ
Where:
- G,H: Left-top padding
- I,J: Right-bottom padding
Example: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&padding=20x20:20x20
Original Image
URL : https://www.thunderimage.com/sample/yosemite.jpg
Padded Image
URL: /transform?url=https://www.thunderimage.com/sample/yosemite.jpg&padding=20x20:20x20&fit-in=true&fill=cyan
Best Practices
- Use
fit_in
when you want to resize an image to fit within certain dimensions without changing its aspect ratio. - Use
stretch
only when you specifically need the image to fit exact dimensions and don’t mind distortion. - When flipping, consider how it might affect text or recognizable objects in the image.
- Combine resize operations with other transformations for more complex image manipulations.
Notes
- The
fit_in
operation will resize the image to fit within the specified dimensions, which may result in one dimension being smaller than specified if the aspect ratio differs. - When using
padding
, remember that it will increase the overall dimensions of the image. - The order of operations matters. For example, applying
padding
beforeresize
will result in a different output than applyingresize
beforepadding
. - All resize operations are performed on the server-side, reducing bandwidth usage and improving performance for your users.
Query Parameters
The URL of the image to be transformed.
The desired width of the image. Use negative value for horizontal flip.
The desired height of the image. Use negative value for vertical flip.
Resize the image to fit within specified dimensions. Format: ExF where E is width and F is height.
Stretch the image to exact dimensions without keeping aspect ratio.
Add padding to the image. Format: GxH:IxJ where G,H is left-top padding and I,J is right-bottom padding.
Response
The response is of type file
.