Transloadit

  • Demos
  • Docs & Help
  • Press
  • Pricing & Signup
hello@transloadit.comCall usBlogLogin

/image/resize robot

Takes a single image file as input and produces a resized version of it. Ideal for generating thumbnails.

Optional parameters

Name Type Default Description
width 1 - 5000 Width of the input image Size for the new image in px
height 1 - 5000 Height of the input image Height for the new image in px
strip boolean false Strips all meta data from the image. Ideal for thumbnails where you want to save every byte.
flatten boolean true Flattens all layers onto your chosen background for a better result from transparent formats to non-transparent formats. Detailed explanation: Layers .
Important: Gif files are not flattened even with a parameter value of true. This is to preserve their animation by default.
If you'd like to flatten gif animations, please use the frame parameter.
correct_gamma boolean false Works around a flaw that is present in most image scaling algorithms. For more information see this article: Gamma error in picture scaling
quality 1 - 100 Quality of the input image or 92 Control the image compression for jpg and png images.
background string "#FFFFFF" Either a hex code or the name of a color to fill the background with (only used for the pad resize strategy).
resize_strategy string "fit" See list of resize strategies.
zoom boolean true If set to false it forces smaller images to not be stretched to the desired width and height. See the list of resize strategies to see which special impact zoom has on your preferred resize strategy.
crop {
x1: integer,
y1: integer,
x2: integer,
y2: integer
}
{} Specify an object that contains the coordinates of the top left and the bottom right corner of a rectangle that should be cropped from the original image(s). An example value is {x1: 80, y1: 100, x2: 160, y2: 180} which would crop an area from (80;100) to (160;180) which has a width and height of both 80px. If crop is set, any width and height parameters are ignored and the resize_strategy is set to crop automatically.
format string Format of the input image Available formats: "jpg", "png", "gif", "tiff"
frame integer null
(all frames)
If you are dealing with animated gif files, you can use this parameter to specify which frame of the gif to use for the operation. Using 1 would select the first frame, 2 the second and so on.
colorspace string "" Set the image colorspace. Check this image magic documentation for available values.
rotation string / boolean / integer true Determine if the image should be rotated. If you want images to be auto-rotated if they are miss-rotated or depend on Exif rotation then set this to true. You can also set this to an integer value to specify the rotation degrees. Additionally, you can optionally use degrees> if you want to rotate only if the image's width exceeds its height (degrees< if the width must be less than the height). Set the value to false to disable auto-fixing of miss-rotated images.

Watermark parameters

Name Type Default Description
watermark_url string "" Url to a png image to overlay over this image.
watermark_position string/array "center" The position you'd like the watermark to have. Available options are: "center", "top", "bottom", "left", "right". You can also combine options, for example "bottom-right".
You can also specify an array of possible values out of which one value will be picked randomly. E.g. ["center","left","bottom-left","bottom-right"]

Note that this will push the watermark into the respective corner. If you want a specific pixel-offset on the watermark you need to include this in the form of padding into the image itself.
watermark_size string "" The size in percent for this watermark.
E.g. a value of "50%" means that the watermark would be 50% of the size of the image it is put on.
watermark_resize_strategy string "fit" Supports "fit" and "stretch".

Resize Strategies

The examples below show the following image resized to 100x100px for each available strategy:

straw apple

Strategy Description
fit Uses width and height as the maximum values for the resize and preserves aspect ratio.

stretch Ignores aspect ratio and resizes the image to the exact width and height given. This may result in a stretched / distorted image.

crop Centers the image within the specified crop frame and discards any overlapping parts. If the source image is smaller than the crop frame, it gets zoomed.

If crop coordinates are provided via the "crop" parameter, the specified image part according to the coordinates is cut from the original and no centering is taking place.

Note: This strategy is not available for the video robots yet.

pad Scales the image to fit and then fills the remaining width and height area with the defined background color (here #aa0000). If you use zoom: false with this strategy, then smaller images will be centered both horizontally and vertically and have the background pad around them.

Demos

  • Resize an image to exactly 75x75 pixels using the pad strategy
  • Convert an image from jpg to png
  • Apply a watermark to uploaded images
  • Crop images to 100x100 pixels
  • Crop images based on cropping coordinates
  • Rotate uploaded images
  • Strip meta data from uploaded images
  • Avoid zooming small images when resizing

Comments

Help

  • Start a new support ticket
  • Browse existing support tickets

Integration

  • Transloadit Basics
  • The minimal integration
  • Building assembly instructions
  • Notifications vs Redirect Url
  • Templates
  • Configuring the jQuery plugin
  • How to add multi-file upload
  • Saving and displaying your files
  • Development Kits
  • NodeJS SDK
  • PHP SDK
  • Ruby Gem
  • iPhone SDK
  • Python SDK

API Documentation

  • API Basics
  • Authentication
  • The response
  • Robots
  • /image/resize
  • /video/encode
  • /video/thumbs
  • /audio/encode
  • /http/import
  • /file/filter
  • Storage Robots
  • /s3/store
  • /sftp/store
  • /cloudfiles/store
  • /youtube/store

More

  • How to set up an Amazon S3 bucket
  • Supported formats & codecs
  • FAQ
  • Community projects
  • About
  • Blog
  • Follow us on Facebook
  • Follow us on Twitter
  • Email
  • Imprint
  • Privacy policy
  • Terms of service