crop
Crop a subimage from the image, and optionaly layout the subimage into the crop box.
parameters
cropping box: coordinates and size (as dimension values) of the subimage inside the original image (x, y, width and height). Default is the image bounding box. If the cropping box bounds exceed the image bounds, they are forced to be inside the image bounds, except in fixed size mode or if layout is none.
insets: instead of a cropping box, you can specify insets (top, right, bottom, left), as also dimension values
centered: boolean value, that switches the bounding box top left corner coordinates (x and y) to center of bounding box. Default is false.
fixed size mode: fixed size parameter, set the fixed size mode. In this mode, the resulting image always has the size of the cropping box, or the fixed size bounding box, if specified. Default is false.
layout: the layout for fixed sized mode. Default is none.
Possible values are:
none: no layout
center: the resulting image is centered in the cropping box
tile: the resulting image is a tile
fit: the resulting image fits the cropping box
fill: the resulting image fills the cropping box
lresize: the resulting image fills the cropping box with seam carving algorithm
JSON object properties
x: the x (easting) of the top-left corner of the cropping box
y: the y (northing) of the top-left corner of the cropping box
width: the width of the cropping box
height: the height of the cropping box
top: the top inset
right: the right inset
bottom: the bottom inset
left: the left inset
centered: to set or unset the centered mode
fixed: to set or unset fixed size mode
layout: the layout
simplified syntax parameters
prefix x: the x (easting) of the top-left corner of the cropping box
prefix y: the y (northing) of the top-left corner of the cropping box
prefix w: the width of the cropping box
prefix h: the height of the cropping box
prefix t: the top inset
prefix r: the right inset
prefix b! the bottom inset
prefix l: the left inset
switch centered: to set or unset the centered mode
switch fixed: to set or unset fixed size mode
prefix fw: width of the fixed size bounding box
prefix fh: height of the fixed size bounding box
prefix ly: the layout
if one of fw
or fh
only is set, both will have the same value.
array type parameters
The array always the cropping box or insets at the end. By default, the values are insets, except if centered mode is activated.
You can specify for cropping box:
two values: the first is x and y and the second is width and height
three values: the first is x, the second is y and the third is width and height
four values, corresponding respectively to x, y, width and height
You can specify for insets:
one value: same values for all insets
two values: the first is top and bottom and the second is right and left
three values: the first is top, the second is right and left and the third is bottom
four values, corresponding respectively to top, right, bottom and left
string or number type parameters
The value is the amount for all top, right, bottom and left insets.
Example 1 - Simple border cropping
{
"crop":"20%"
}
Maldives: W400×H225 |
Maldives: W320×H180 |
Simplified syntax: t_20p,c_crop
Example 2 - Box cropping
{
"crop":{"x":80,"y":80,"width":135,"height":65}
}
Boat in clear blue ocean: W400×H267 |
Boat in clear blue ocean: W135×H65 |
Simplified syntax: x_80,y_80,w_135,h_65,c_crop
Examples - Focus crop, fixed size and layouts
Iceland: W300×H409 |
Example 1 - No layout, no fixed size
{
"crop":{
"x":0,
"y":0,
"width":"200",
"height":"150",
"centered":true
}
}
Iceland: W200×H150 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,c_crop
Example 2 - No layout, fixed size
Iceland: W100×H75 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,fixed,c_crop
Example 3 - Tile layout, fixed size
Iceland: W200×H150 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,fixed,ly_tile,c_crop
To get a transparent background, instead of black, convert the image to png. To get a background in the color you want, then use the background command. Then you can transform back the image to the original format.
Iceland: W200×H150 |
Simplified syntax: e_png,c_format,x_0,y_0,w_200,h_150,centered,fixed,ly_tile,c_crop,bg_lavender,c_background,e_$org,c_format
Example 3 - Center layout, fixed size
Iceland: W200×H150 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,fixed,ly_center,c_crop
Example 4 - Fit layout, fixed size
Iceland: W200×H150 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,fixed,ly_fit,c_crop
Example 5 - Fill layout, fixed size, changing bounds
Iceland: W200×H200 |
Simplified syntax: x_0,y_0,w_200,h_150,centered,fixed,ly_fill,fw_200,fh_200,c_crop