Resize
Resize layer (resize) resizes data (image + annotation) to the certain size.
1
{
2
"action": "resize",
3
"src": ["$data1"],
4
"dst": "$data2",
5
"settings": {
6
"width": 800,
7
"height": 600,
8
"aspect_ratio": {
9
"keep": true
10
}
11
}
12
}
Copied!
  • "aspect_ratio": "keep" โ€” flag (true or false). If true result should save original proportions.
  • width โ€” width in pixels or -1. If value is equal to -1 and "keep": true then for specific height width will be automatically computed to keep aspect ratio. The case when value is equal to -1 and "keep": false is not allowed.
  • height โ€” height in pixels or -1. If value is equal to -1 and "keep": true then for specific width height will be automatically computed to keep aspect ratio. The case when value is equal to -1 and "keep": false is not allowed.

Use case: resize to specific width

1
{
2
"action": "resize",
3
"src": ["$data1"],
4
"dst": "$data2",
5
"settings": {
6
"width": 800,
7
"height": -1,
8
"aspect_ratio": {
9
"keep": true
10
}
11
}
12
}
Copied!
Result will be the following:
Height will be automatically computed and it is 600 px in this example.

Use case: resize to specific height

1
{
2
"action": "resize",
3
"src": ["$data1"],
4
"dst": "$data2",
5
"settings": {
6
"width": 400,
7
"height": 300,
8
"aspect_ratio": {
9
"keep": true
10
}
11
}
12
}
Copied!
Result will be the following:
Width will be automatically computed and it is 400 px in this example.

Use case: resize to specific width and height without keeping aspect ratio

1
{
2
"action": "resize",
3
"src": ["$data1"],
4
"dst": "$data2",
5
"settings": {
6
"width": 2000,
7
"height": 500,
8
"aspect_ratio": {
9
"keep": false
10
}
11
}
12
}
Copied!
Result will be the following:

Use case: resize to specific width and height with keeping aspect ratio

1
{
2
"action": "resize",
3
"src": ["$data1"],
4
"dst": "$data2",
5
"settings": {
6
"width": 2000,
7
"height": 500,
8
"aspect_ratio": {
9
"keep": true
10
}
11
}
12
}
Copied!
Result will be the following:
As we can see, additional black padding is added to save both certain image size (width=2000 and height=500) and original proportions.
Last modified 1yr ago