Mesh depth size based on texture width

Hello Everyone,

I am stuck and need some help.
I am trying to scale mesh depth based on texture width as shown in the image below. I exported box mesh from Blender and I came close to something similar using this approach:

size = texture.image.width/100;
box.scale.y = size;

But I know this is not the right approach. Can anyone suggest a better way of doing this?
I also tried calculating the ratio of the image, and using that, but cannot get it to work correctly as I wish only the depth of the box to change.

Thank you for reading this and for helping :slight_smile: