Welcome to our Support Center

keep_aspect_ratio_policy

keep_aspect_ratio_policy : enum, this attribute describes how to interpret theΒ sizesΒ input with regard to keeping the original aspect ratio of the input, and it is not applicable when theΒ scalesΒ input is used.

 

Given a set ofΒ sizes, associated with a subset ofΒ axesΒ (explicitly provided or default), and assumingΒ dΒ =Β axes[i], withΒ iΒ being the index of the providedΒ sizes.

IfΒ keep_aspect_ratio_policyΒ isΒ "stretch", the original aspect ratio is disregarded, and the input is resized to the specified size:Β out_size[d]Β =Β sizes[i]

IfΒ keep_aspect_ratio_policyΒ isΒ "not_larger", the sizes are adjusted so that no extent of the output is larger than the specified size, while keeping the original aspect ratio:

scale = Min(sizes[i] / in_size[d])
out_size[d] = round_int(scale * in_size[d])

IfΒ keep_aspect_ratio_policyΒ isΒ "not_smaller", the sizes are adjusted so that no extent of the output is smaller than the specified size, while keeping the original aspect ratio:

scale = Max(sizes[i] / in_size[d])
out_size[d] = round_int(scale * in_size[d])

For non-resizable axes (those not specified inΒ axes), the output size will be equal to the input size.

Note:Β round_intΒ stands for computing the nearest integer value, rounding halfway cases up.

Table of Contents