How to add texture to the node so that it should not be look like stretched or compressed in SceneKit?

I am going to detect vertical plane and after detection going to place photo frame(3D object) on that plane. Frame is of 8*12 inches. Texture image size putting in frame is 800*1200 pixels. Now I want to put images dynamically with different sizes.

As far as I got is need to change material’s contentTransform property(i.e. need to change scale and offset). I tried to change scale and offset in SceneKit editor but not getting how to calculate that contentTransform so that add it programmatically for dynamic image size.


(In short I want to display images in frame as we can see images when we open in gallery i.e. Image’s size changes wrt aspect ratio of device size. If image’s width is larger than height then there is black horizontal strip above and below image and if image’s height is larger than width then there is black vertical strip before and after image.)


How to achieve this?