Changing ImageLabel’s size depending on ImageId’s ratio?

The title says it all. Is there anyway to do this? Thanks

I’m going to assume you want to keep an image at a certain aspect ratio, regardless of the player’s screen ratio, in which case don’t have to use a script, but can use an object called UIAspectRatioConstraint.

To be able to use this ui constraint properly, you’ll need to know the aspect ratio of the image, which I don’t think you can get from the ImageId. If you don’t already know the aspect ratio of the image and didn’t upload it, I guess the next best thing you can do is guess and check, and then once you find a good looking aspect ratio for your image, lock it in place with the ui constraint I linked above.

Also, this question would better fit in Art Design Support - Developer Forum | Roblox since it deals purely with UI, but maybe you expected scripting to be involved, which is why you put it here.

I hope I interpreted what you neded correctly

Sorry for the confusion.

I am making a little thing in my game where a player can change the ImageId of an ImageLabel. I want that image label to be able to change UDim2 sizes so that it matches with the correct ratio of the image the player selects.

Thanks for the help though!

Maybe reference an offset-to-scale script?

Oh, what did you mean by that?

So I did a little searching on the devforum and found this:

a way to find the original size of an ImageId. With this, you can calculate the aspect ratio of an ImageId and change the image label’s side accordingly, although it seems to be limited to images that are PNGs.

1 Like

There are free model scripts with code that converts Offset (pixels) to Scale for GUIs.