Resize mesh according to picture size

I have a blueprint that create a framed picture - a frame with a metallic material applied, and a box inside it with a picture applied as a material on the front of the box.

I want the frame to be resized automatically according to the size of the given picture material. for example, if i use a picture that’s 800*1000 pixels, the size of the X and Z dimensions of the frame will be 800 and 1000 units.
The end goal is an object that i just drag a picture on to and it creates a framed picture in the right size.

I created parameters that adjust the size of the frame and the picture but I set them manually for now.
I couldn’t find a way to set them in the blueprint - a way to access the size of the source image used for a material.

How can i do this? can this be done using either C++ or blueprint?
Thanks!

Hey there @HAUNT-E-D! depending on how your object is scaled and it’s forward vector you’d have to adjust the bits at the end. When you set your texture2D you can get the texture2D’s pixels then scale the frame SM like so.

2 Likes

Thanks for your reply!
I didn’t really knew the difference between a material and a texture.

I ended up creating a simple material instance with a texture as parameter, and in the geometry blueprint I created an instance of that material with the given texture, so the texture can be accessed directly from there so I can use GetSizeX/Y.

1 Like