I made a plugin to get the actual image size dimensions of any Roblox image in Studio

When working in Studio, sometimes it is useful to know the actual resolution of an image you’re dealing with. This can come in handy for using the slice feature for a 9-slice or a spritesheet, making an image be the pixel-perfect size to prevent resize artifacts, or wanting to maintain the correct aspect ratio when resizing. This has been suggested a couple times, so I thought I’d spend a few hours making a plugin that does this, for the greater good! :slight_smile:

Here is a video demonstrating how the plugin works:
https://gfycat.com/CrispOrneryAmericanriverotter

The plugin has the following options when you select something with an Image/Texture/Graphic/other image property:

  • Get image size: Displays the image dimensions and prints them into the output
  • Set size to image size: This will set the “Size” property of whatever you’re selecting (or the parent of your selection if you are selecting a decal or texture) to the actual proper resolution of the image. This is great for pixel-perfect icons in GUIs. Also great if you want giant parts with pictures on them.
  • Set size, maintain width - Sets the height to whatever would be proportional relative to the image’s aspect ratio, keeping the width the same. Great for parts with decals or when you want to size-up an icon in one axis, then just click this button to automatically size up the other one correctly.
  • Set size, maintain height - Same as above, but changes the width.

It also supports objects with more than one image property, like a ScrollingFrame.

The plugin also has another feature: when you insert a Decal from the Toolbox into an ImageButton or ImageLabel, it will take the Texture from the Decal and set that as the Image for the ImageButton/Label and deletes the decal. This is just a quality-of-life feature so you can easily set your GUI images without needing to copy/paste from decals. This feature can be disabled.

Install the plugin

This plugin uses a web API to get the dimensions, so HTTP requests must be enabled in your place. The web server script is also open source on GitHub. It pulls from Animinus’ Web API for property information so it should always work, even if Roblox adds more objects with image properties. While it’s not possible to distinguish Image content from other content (sounds, meshes, linked scripts), the plugin is hard coded to ignore all scripts, Sounds, KeyframeSequences, and Animations, and the property name “MeshId”.

The plugin is currently always enabled, so the menu will appear whenever you select an image object. I made this decision so it would be easier to use and so that you don’t have to deactivate other plugins when using them to build/edit. The menu is draggable, however. The plugin toolbar button will only appear if you need to press it to try again if HTTP requests weren’t enabled when the game started.

I hope at least someone finds this useful. Suggestions welcome, if you do. :smiley:

45 Likes

This sounds handy. :open_mouth:

nice

This will may be very useful for blueprints

1 Like

This will definitely help with scaling blueprints for Disneyland!

Bless You ,Bless you. I will be recreating this for my own plugin, but for now, You are my savior.

This is really great and helpful, thank you so much!

I’m having trouble getting this to work

Same here. I’m trying to use the plugin to resize some parts with decals on them to get the correct aspect ratio.

Made a fixed and working version:

1 Like

Hello,

I realize that this topic has been idle for more than a month. But I’ve been trying for a couple hours, yet I’m unable to quite figure out why the GetSize function is returning an error.

If you input any image ID behind https://image-size.eryn.io/image-size/, it’ll return an error. For example: https://image-size.eryn.io/image-size/8740888472. I’ve tried including the “rbxassetid://” in the link and it’s still returning an error. For example: https://image-size.eryn.io/image-size/rbxassetid://8740888472

I don’t reckon there’s any problems with my script either since it’s 99% the same as your GetSize function.

Script (Server-Sided)
function GetImageSize(id)
	if not id then
		error("No ID")
	end
	if id:sub(1, 11) == "rbxasset://" then
		error("Cannot get the size of local assets")
	end

	id = id:gsub("[^%d]", "")

	if #id == 0 then
		error("Invalid texture id")
	end

	if SizeCache[id] then
		return SizeCache[id].width, SizeCache[id].height
	end

	local data = Http:JSONDecode(Http:GetAsync("https://image-size.eryn.io/image-size/" .. id))

	if data.error then
		error("Web API returned an error: probably because selected property content is not an Image")
	end

	SizeCache[id] = data

	return data.width, data.height
end

Thanks for your time,
Razor

Should be fixed

from the source code it does not support images with rbxasssetid://

Sounds like a nice plugin and could help me a lot while making some real-life scale models so I decided to have a try but seems I have got a problem bellow

It keeps showing an error when pressing the “Get Image Size” button. I have turned on the HTTP so I would like to ask what’s going on and if is it able to fix it and how can you fix it if you can.

1 Like