A way to get the width and height of a Texture in pixels

Right now there is no way to find out the height and width of a Texture’s original file. This is really unfortunate because it makes it impossible to figure out the correct aspect ratio for Decals if you do not have the used Texture’s original file somewhere on your PC. I often have to ask my co-developers for the dimensions of the original file of a Texture they made so I don’t find myself guessing how wide I have to make a Part with a Decal on it. Right now it’s also impossible to have a Script correctly resize a Part with a Decal on it because there is no method to return a Texture’s dimensions. A way to return the width and height or a Texture would fix these problems.

19 Likes

For now, this will scale your image down to proper aspect ratio given your imagelabel/button is a square. http://www.roblox.com/Thumbs/Asset.ashx?width=110&height=110&assetId=446747814
http://www.roblox.com/Thumbs/Asset.ashx?width=420&height=420&assetId=446747814

2 Likes

And did images that DON’T have a 1:1 ratio?

Itll make your image have the original aspect ratio, your imagelabel will just need to be a square or youll skew it. Notice in my link the image isnt stretched out despite it being uploaded as a rectangle.

1 Like

2 Likes

I’d still suggest moving away from giving objects like decals and imagelabels an ID and creating a generic image object to give them instead. Are you going to add the ability to get the size to every object that uses images? Maybe add it to ContentProvider? It would fit in more with that generic image object as a readonly property. That generic image object would also provide the benefit of not needing to update every single object that uses an Image property whenever you add various image-related properties and stop desync between objects (ImageLabels can slice but decals/textures can’t, textures can tile themselves, but imagelabels can’t, meshes/imagelabels have a Color3 property while decals/textures don’t, etc).

1 Like

Sorry if I’m extra late, I saw this as an existing topic that I was interested in. Has this feature been added yet, I have some cases where I could use this.

Just an annual reminder that textures aren’t loaded at all on the server.

4 Likes

Did you mean this as if to say “This won’t work, because textures aren’t loaded on the server”? If so, I am just a little confused because even if they aren’t loaded on the server, this feature could still work in Studio and on the client (perhaps as a method of ContentProvider, which is only present on the client). :slight_smile:

2 Likes

I just created a plugin that can do this (along with some other easy resizing features)!. It’s not perfect since it has to use HttpService, but it works until (hopefully) this is implemented officially.

4 Likes

Nice! Until Roblox adds the feature, I’ll make sure to use your plugin!
You don’t mind if I inspect the plugin code, right?

Not at all :slight_smile:

2 Likes