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, 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

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