Calculating the correct aspect ratio

helö again

my patch displays randomly selected images that vary in size and aspect ratio. until now, i haven’t found a proper way to calculate suitable values needed to transform either thru the aspect ratio node nor transform(2d). i could work with a list of fixed values, but that’s a lame and unflexible way to go. i’m sure this is a known task, any hints on how to solve this?

thx, pat

hi pat,
one possible way would be to use the info (texture) node to get the size and then tranform according to that.

hi partick, attached there is a patch that does what m4d explains. I divide the width and the height of the texture, so i obtain the aspect ratio. Multiplying the width to this value you have the correct proportions. Then i used a aspect ratio in the renderer so the aspect ratio of the contens is always the same of the aspectratio of the window.

aspect_ratio_of_texture.v4p (7.2 kB)

maybe the Texture Scale node …

lovely!

thanks m4d and thanks screamer for solving this last puzzle fragment faster than expected! i’d to ask for what screamer explained anyway now, that’s done too.
assuming that it’s a common task to deal with varying aspect ratios, this would be a worthwhile addition to the wiki.

appreciated!