Service Endpoint

https://edge.sandcage.com/<YOUR REAL-TIME PROCESSING ENDPOINT KEY>/0.2/crop


Request Parameters

url*
requiredThe relative or absolute URL path of the source image.
To mask the absolute path of a given source file an origin mapping can be assigned to the Realtime API Key.
tl

integer

0...

optionalThe upper-left corner coordinates (x,y) of the image to return.
Accepts one or both of the values for the "x" and "y" coordinates, which must be:
  • equal to or larger than "0"; and
  • equal or smaller than the respective "x" and "y" coordinate values of "br"
Example: x:10,y:20
If either of the values is omitted, then it will default to "0".
br

integer

0...

optionalThe bottom-right corner coordinates (x,y) of the image to return.
Accepts one or both of the values for the "x" and "y" coordinates, which must be:
  • equal to or smaller than dimensions of the source image, minus 1 pixel.
    E.g.: If a source image has width 768 pixel and height 512 pixel, the maximum allowed values for the "x" and "y" coordinates will be "767" and "511" respectively; and
  • equal or larger than the respective "x" and "y" coordinate values of "tl"
Example: x:350,y:400
If either of the values is omitted, then it will default to maximum dimensions available in the source image.
compress
optionalA boolean representation of whether or not the resulting image should be compressed.
Available options:
  • true
  • false

Default is false.
format
optionalWhether or not the file format of the resulting image should be converted to one that will produce a file with smaller file size. The returned image file format will depend on the support of the client software (e.g. browser). If omitted or set to false, then the returned image file format will be the same as the source image.
Available options:
  • auto
  • false

Default is false.
progressive
optionalA boolean representation of whether or not the file is encoded in a format that allows for progressively higher detail to be decoded prior to the complete image being delivered. Some browser limitation apply (see here). If "compress" is omitted or set to "false" it will be overrided and set to "true".
Only available for JPEGs.
Available options:
  • true
  • false

Default is false.
optimize
optionalA boolean representation of whether the engine will attempt to optimize the Huffman coding tables. If "compress" is omitted or set to "false" it will be overrided and set to "true".
Only available for JPEGs.
Available options:
  • true
  • false

Default is false.

Basic Crop Example Request

This request will return a vertically cropped image with height 300 pixels. Since only the "y" values were specified for the "tl" and "br" parameters, the width will be the same as the source image.

https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=y:100&br=y:399

Result


Horizontally Cropped Example Request

This request will return a horizontally cropped image with width 300 pixels. Since only the "x" values were specified for the "tl" and "br" parameters, the height will be the same as the source image.

https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=x:150&br=x:449

Result


Horizontally and Vertically Cropped with Compression Enabled Example Request

This request will return a horizontally and vertically cropped image with width and height of 400 pixels. Since the "x" value for the "tl" parameter and the "y" value for the "br" parameter were not set, these will respectfully default to "0" and the height of the original image. The returned image will also be compressed.

https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=y:112&br=x:399&compress=true

Result


Horizontally and Vertically Cropped with Auto-Format Enabled Example Request

This request will return a horizontally and vertically cropped image with width and height of 400 pixels. Since the "y" value for the "br" parameter was not set, it will default to the height of the original image. The returned image will also be converted to the most suitable file format.

https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=x:100,y:112&br=x:499&format=auto

Result


Horizontally and Vertically Cropped with Compression and Auto-Format Enabled Example Request

This request will return a horizontally and vertically cropped image with width and height of 300 pixels. The returned image will also be compressed and converted to the most suitable file format.

https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=x:150,y:150&br=x:449,y:449&format=auto&compress=true

Result


Give it a try

You can adjust the options below to produce the respective parameters and see the resulting image.

0px
0px
768px
512px
https://edge.sandcage.com/18e102bea84860764a07dca77adbf145157751b7/0.2/crop?url=p%2Fa%2Fimg%2Fothers%2Fbefore.jpg&tl=x:0,y:0&br=x:767,y:511

Result


Still Have Questions?

We're always happy to help with code and integrations. Talk to us!