The /image/resize Robot

We can resize, crop, and (auto-)rotate images, as well as watermark them.
The /image/resize
Robot resizes, crops, changes colorization, rotation, and applies text and watermarks to images.
Parameters
Name | Type | Default | Description |
---|---|---|---|
use
|
(required) String / Array of Strings | GeneralSpecifies which Step(s) to use as the input to this Robot.Special Step namesA special Step name is":original" , which provides user uploads handled by Transloadit.
Providing several Steps as inputYou can add arrays touse several Steps:
Step bundlingSome Robots can gather several Step results for a single invocation. For example, the /file/compress Robot would normally create one Zip file for each file passed to it. If you'd setbundle_steps to true,
however, it will create one archive containing all the result files from
all Steps you give it. To enable bundling, provide an object
like the one below to the use parameter:
This is a crucial parameter
for the /video/adaptive Robot,
otherwise you'll generate 1 playlist for each viewing quality. Keep in mind that all input Steps must be present in your Template. If one of them is missing, no result is generated because the Robot waits indefinitely for all input Steps to be finished. Group by originalSticking with the /file/compress Robot example, you can setgroup_by_original to true , in order to create a separate Zip file
for each of your uploaded or imported files, instead of
creating one archive containing all originals (or one per resulting file). This is a crucial parameter
for the /media/playlist Robot.
DemoSee a demo for theuse parameter
here.
|
|
format
|
String | Auto | The output format for the modified image.
Some of the most important available formats are "jpg" , "png" ,
"gif" , "tiff" and "pdf" . For a complete lists of all formats that we
can write to please check our supported image formats
list. If this parameter is not
specified it will default to the format of the input image.
|
width
|
Integer(1 -5000 )
|
Auto | Width of the new image, in pixels. If not specified, will default to the width of the input image. |
height
|
Integer(1 -5000 )
|
Auto | Height of the new image, in pixels. If not specified, will default to the height of the input image. |
resize_strategy
|
String | "fit"
|
See the list of available resize strategies. |
zoom
|
Boolean | true
|
If this is set to false , smaller images will not be stretched to the
desired width and height. For details about the impact of zooming for your
preferred resize strategy, see the list of available resize
strategies.
|
crop
|
Object / JSON String | null
|
Specify an object containing coordinates for the top left and bottom right
corners of the rectangle to be cropped from the original image(s). For
example:
will crop the area from (80, 100) to (160, 180) which is a square whose width and height are
80px. If crop is set, the width and height parameters are ignored, and
the resize_strategy is set to crop automatically.
You can also use a
JSON string of such an object with coordinates in similar fashion: "{
\"x1\": <Integer>, \"y1\": <Integer>, \"x2\": <Integer>, \"y2\": <Integer>
}"
To crop around human faces, see our /image/facedetect Robot.
|
gravity
|
String | center
|
The direction from which the image is to be cropped, when "resize_strategy" is set to "crop" ,
but no crop coordinates are defined. The available options
are "center" , "top" , "bottom" , "left" , and "right" . You can also
combine options with a hyphen, such as "bottom-right" .
|
strip
|
Boolean | false
|
Strips all metadata from the image. This is useful to keep thumbnails as small as possible. |
alpha
|
String | ""
|
Gives control of the alpha/matte channel of an image. Valid options are "Activate" , "Background" , "Copy" , "Deactivate" , "Extract" , "Off" , "On" , "Opaque" , "Remove" , "Set" , "Shape" , "Transparent"
|
preclip_alpha
|
String | ""
|
Gives control of the alpha/matte channel of an image before applying the clipping path via clip: true . Valid options are "Activate" , "Background" , "Copy" , "Deactivate" , "Extract" , "Off" , "On" , "Opaque" , "Remove" , "Set" , "Shape" , "Transparent"
|
flatten
|
Boolean | true
|
Flattens all layers onto the specified background to achieve better
results from transparent formats to non-transparent formats, as explained
in the ImageMagick
documentation.
To preserve animations, GIF
files are not flattened when this is set to true . To flatten GIF
animations, use the frame parameter.
|
correct_gamma
|
Boolean | false
|
Prevents gamma errors common in many image scaling algorithms. |
quality
|
Integer(1 -100 )
|
Quality | Controls the image compression for JPG and PNG images.
Please also take a look at our
/image/optimize
Robot.
Before: ![]() Quality 92 applied:
![]() Quality 40 applied:
![]() If this parameter is not specified it will default to the quality of the input image, or 92
|
background
|
String | "#FFFFFF"
|
Either the hexadecimal code or name of the color used to fill the background (only used for the pad resize strategy). By default, the background of transparent images is changed to white. For details about how to preserve transparency across all image types, see this demo. |
frame
|
Integer / Null | null
|
Use this parameter when dealing with animated GIF files to specify which
frame of the GIF is used for the operation. Specify 1 to use the first
frame, 2 to use the second, and so on. null means all frames.
|
colorspace
|
String | ""
|
Sets the image colorspace. For details about the available values, see the
ImageMagick
documentation.
Please note that if you were using "RGB" , we recommend using "sRGB"
instead as of 2014-02-04. ImageMagick might try to find the most efficient
colorspace based on the color of an image, and default to e.g. "Gray" .
To force colors, you might then have to use this parameter in combination
with type "TrueColor"
|
type
|
String | ""
|
Sets the image color type. For details about the available values, see the
ImageMagick
documentation.
If you're using colorspace , ImageMagick might try to find the most
efficient based on the color of an image, and default to e.g. "Gray" . To
force colors, you could e.g. set this parameter to "TrueColor"
|
sepia
|
Integer(0 -99 ) / Null
|
null
|
Sets the sepia tone in percent.
Before: ![]() After setting sepia to 90 :
![]() After setting sepia to 40 :
![]() After setting sepia to 10 :
![]() |
rotation
|
String / Boolean / Integer | true
|
Determines whether the image should be rotated. Set this to true to
auto-rotate images that are rotated in a wrong way, or depend on EXIF
rotation settings. You can also set this to an integer to specify the
rotation in degrees. You can also specify "degrees" to rotate only when
the image width exceeds the height (or "degrees" if the width must be
less than the height). Specify false to disable auto-fixing of images
that are rotated in a wrong way.
|
compress
|
String / Null | null
|
Specifies pixel compression for when the image is written. Valid values
are "None" , "BZip" , "Fax" , "Group4" , "JPEG" , "JPEG2000" ,
"Lossless" , "LZW" , "RLE" , and "Zip" . Compression is disabled by
default.
Please also take a look at our
/image/optimize
Robot.
|
blur
|
String / Null | null
|
Specifies gaussian blur, using a value with the form {radius}x{sigma} .
The radius value specifies the size of area the operator should look at
when spreading pixels, and should typically be either "0" or at least
two times the sigma value. The sigma value is an approximation of how many
pixels the image is "spread"; think of it as the size of the brush used to
blur the image. This number is a floating point value, enabling small
values like "0.5" to be used.
|
progressive
|
Boolean | false
|
Interlaces the image if set to true , which makes the image load
progressively in browsers. Instead of rendering the image from top to
bottom, the browser will first show a low-res blurry version of the images
which is then quickly replaced with the actual image as the data arrives.
This greatly increases the user experience, but comes at a cost of a file
size increase by around 10%.
|
transparent
|
String | ""
|
Make this color transparent within the image. |
trim_whitespace
|
Boolean | false
|
This determines if additional whitespace around the image should first be
trimmed away. If you set this to true this parameter removes any edges
that are exactly the same color as the corner pixels.
|
clip
|
Boolean / String | false
|
Apply the clipping path to other operations in the resize job, if one is
present. If set to true , it will automatically take the first clipping
path. If set to a String it finds a clipping path by that name.
|
negate
|
Boolean | false
|
Replace each pixel with its complementary color, effectively negating the image. Especially useful when testing clipping. |
density
|
String | null
|
While in-memory quality and file format depth specifies the color
resolution, the density of an image is the spatial (space) resolution of
the image. That is the density (in pixels per inch) of an image and
defines how far apart (or how big) the individual pixels are. It defines
the size of the image in real world terms when displayed on devices or
printed.
You can set this value to a specific width or in the format
width xheight .
If your converted image has a low resolution, please try using the density
parameter to resolve that.
|
output_meta
|
Object | {}
|
Allows you to specify a set of meta data that is more expensive on cpu power to calculate,
and thus is disabled by default to keep your Assemblies processing fast.
You can add "has_transparency": true in this object to extract if the image contains transparent parts.
|
Demos
Our /image/resize Robot can be used in combination with other Robots, to create powerful workflows unique to your use case. Here are a few example scenarios that you can try live on our website:
- Add a sepia effect to an image
- Resize and apply transparency, based on a clipping path inside an image
- Avoid zooming small images when resizing
- Change the quality of a JPEG
- Convert an image from JPG to PNG
- Convert an image to WebP
- Crop an image based on cropping coordinates
- Crop a picture to 100×100 pixels
- Apply a watermark to images
- Properly preserve transparency across image types
- Remove a color around the edges of an image
- Resize an image to exactly 75×75 pixels
- Rotate uploaded images
- Apply a text watermark to images
Blog posts about the /image/resize Robot
We wrote the following posts about the /image/resize Robot on our blog:
- Ghostscript security incident (VU#332928) August 30, 2018
- Accidental breaking change for the crop resize strategy June 6, 2018
- Launching a new version of ImageMagick July 20, 2017
- A word on ImageTragick (CVE-2016–3714) May 4, 2016
- Performance Upgrades March 4, 2015
- Kicking Transloadit Into Gear for the New Year February 1, 2015
- On Upgrades & Goodbyes August 8, 2014
- We Have Added Support for SVG Images March 23, 2013
- Adding Support for Image Interlacing December 11, 2012
- Adding Support for Image Blurring October 21, 2012
- New Resize Strategy `fillcrop` Available February 14, 2012
- Adding Support for Audio Encoding November 21, 2011
- New `frame` Parameter for the /image/resize Robot May 26, 2011
- Adding More Options to Our Image Resize Robot May 9, 2011
- Now Offering Support for Image Rotation April 1, 2011
- Adding Support for Cropping by Coordinates January 31, 2011
- Is Your Image Scaling Software Up To Scratch? October 15, 2010
Did you know?
You can easily combine Robots to create powerful workflows, unique to your business.
This is the power of Transloadit.