Resize layer (resize
) resizes data (image + annotation) to the certain size.
{
"action": "resize",
"src": ["$data1"],
"dst": "$data2",
"settings": {
"width": 800,
"height": 600,
"aspect_ratio": {
"keep": true
}
}
}
-
"aspect_ratio": "keep" — flag (
true
orfalse
). Iftrue
result should save original proportions. -
width
— width in pixels or-1
. If value is equal to-1
and"keep": true
then for specificheight
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 specificwidth
height
will be automatically computed to keep aspect ratio. The case when value is equal to-1
and"keep": false
is not allowed.
{
"action": "resize",
"src": ["$data1"],
"dst": "$data2",
"settings": {
"width": 800,
"height": -1,
"aspect_ratio": {
"keep": true
}
}
}
Result will be the following:
Height will be automatically computed and it is 600 px in this example.
{
"action": "resize",
"src": ["$data1"],
"dst": "$data2",
"settings": {
"width": 400,
"height": 300,
"aspect_ratio": {
"keep": true
}
}
}
Result will be the following:
Width will be automatically computed and it is 400 px in this example.
{
"action": "resize",
"src": ["$data1"],
"dst": "$data2",
"settings": {
"width": 2000,
"height": 500,
"aspect_ratio": {
"keep": false
}
}
}
Result will be the following:
{
"action": "resize",
"src": ["$data1"],
"dst": "$data2",
"settings": {
"width": 2000,
"height": 500,
"aspect_ratio": {
"keep": true
}
}
}
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.