ImageLabel

Show Deprecated

An ImageLabel renders a rectangle, like a Frame does, with an image. The image must be a decal uploaded to the Roblox website. The display of the image can be manipulated through the ImageLabel.ImageColor3 and ImageLabel.ImageTransparency properties. To display only the image and hide the rectangle, set GuiObject.BackgroundTransparency to 1.

The image is scaled to fit the entirety of the rectangle, but remember that images look best when displayed at their native resolution. Before uploading your image asset, you may want to apply alpha bleeding and take a few more steps when building UI for high-DPI devices (like phones).

Advanced ImageLabel usage

Code Samples

Image Animation using Spritesheet

1-- Place this in an ImageLabel/ImageButton with size 256x256
2local imageLabel = script.Parent
3
4-- The following image is 1024x1024 with 12 frames (256x256)
5-- The frames play an animation of a man throwing a punch
6imageLabel.Image = "rbxassetid://848623155"
7imageLabel.ImageRectSize = Vector2.new(256, 256)
8
9-- The order of the frames to be displayed (left-to-right, then top-to-bottom)
10local frames = {
11 Vector2.new(0, 0),
12 Vector2.new(1, 0),
13 Vector2.new(2, 0),
14 Vector2.new(3, 0),
15 Vector2.new(0, 1),
16 Vector2.new(1, 1),
17 Vector2.new(2, 1),
18 Vector2.new(3, 1),
19 Vector2.new(0, 2),
20 Vector2.new(1, 2),
21 Vector2.new(2, 2),
22 Vector2.new(3, 2),
23}
24
25-- Animate the frames one at a time in a loop
26while true do
27 for _, frame in ipairs(frames) do
28 imageLabel.ImageRectOffset = frame * imageLabel.ImageRectSize
29 task.wait(0.1)
30 end
31end

Summary

Properties

The image content displayed by the UI element.

Determines how a rendered image will be colorized.

The offset in pixels of the sub-area of an image to be displayed.

Determines the size in pixels of the sub-area of an image to be displayed.

Determines the transparency of the rendered image.

Indicates whether the Image has finished loading from the Roblox website.

READ ONLY
NOT REPLICATED

Selects the image resampling mode for the label.

Determines how an image will scale if displayed in a UI element whose size differs from the source image.

Sets the slice boundaries of a 9-sliced image.

Scales the 9slice edges by the specified ratio.

Sets the tiling size of the ImageLabel.

Events

Methods

Properties

Image

The Image property is a content-type property that should hold the asset ID of a Decal or Image on the Roblox website. It functions identically to Decal.Texture with regards to loading the image from the Roblox website. The rendered image will be colorized using ImageLabel.ImageColor3. It is possible to make the image render as tiled, scaled to fit, or 9-sliced, by adjusting the ImageLabel.ScaleType property.

ImageColor3

The ImageColor3 property determines how an image is colorized. When set to white, no colorization occurs. This property is very useful for reusing image assets: If the source image is completely white with transparency, you can set the entire color of the image at once with this property.

ImageRectOffset

Allows the partial display of an image in conjunction with ImageLabel.ImageRectSize. This property determines the pixel offset (from the top-left) of the image area to be displayed.

This property behaves identically to ImageButton.ImageRectSize.

ImageRectSize

Allows the partial display of an image in conjunction with ImageLabel.ImageRectOffset. This property determines the pixel size of the image area to be displayed. If either dimension is set to 0, the entire image is displayed instead.

This property behaves identically to ImageButton.ImageRectOffset.

ImageTransparency

ImageTransparency determines the alpha of a UI element's rendered image. A value of 0 is completely opaque, and a value of 1 is completely transparent (invisible). This property behaves similarly to GuiObject.BackgroundTransparency or BasePart.Transparency.

IsLoaded

Read Only
Not Replicated

The IsLoaded property indicates if the ImageLabel.Image property finished loading from the Roblox website. Images declined by moderation will never load.

ResampleMode

Determines how the image looks when it is scaled.

By default, the image smooths out texture when displayed on the screen larger or smaller than its size in texture memory. When set to Enum.ResamplerMode.Pixelated, the image preserves the sharp edges of pixels.

ScaleType

The ScaleType property determines in what way an ImageLabel.Image is rendered when the UI element's absolute size differs from the source image's size.

By default, this property is Enum.ScaleType.Stretch, which will simply stretch/compact the image dimensions so it fits the UI element's space exactly. Since transparent pixels are set to black when uploading to the Roblox website, transparent images should apply alpha blending to avoid a blackish outline around scaled images.

For Enum.ScaleType.Slice, the ImageLabel.SliceCenter property will be revealed in the Properties window. This is for nine-slice UI: when scaling up, the corners will remain the source image size. The edges of the image will stretch to the width/height of the image. Finally, the center of the image will stretch to fill the center area of the image.

Finally, for Enum.ScaleType.Tile, the ImageLabel.TileSize property will be revealed in the Properties window. This is for tiled images, where the size of each image tile is determined by the ImageLabel.TileSize property.

SliceCenter

The SliceCenter property sets the slice boundaries of a 9-sliced image when ImageLabel.ScaleType is set to Enum.ScaleType.Slice. Please note that this property is only visible in the Studio Properties Pane if ImageLabel.ScaleType is set to Enum.ScaleType.Slice. Select this property and click the "..." button to open the 9-Slice Editor, a built-in visual editor for setting the slice boundaries.

To learn more about 9-sliced images, check out this tutorial: UI 9 Slice Design.

SliceScale

Scales the 9slice edges by the specified ratio. This means that the edges around the 9slice will grow as if you'd uploaded a new version of the texture upscaled. Defaults to 1.0.

As a multiplier for the borders of a 9slice, it is useful for reusing one rounded corner image for multiple radii.

See also:

TileSize

TileSize sets the tiling size of the ImageLabel. The default UDim2 values are 1,0,1,0. The scale component of the UDim2 will scale the tile based on the size of the ImageLabel. The offset is in raw pixels. The tiling starts at the upper left-hand corner of the image. For example a scale of 0.5 will mean the tile will be half the size of the ImageLabel (in the corresponding axis).

This property is only active if the ScaleType for the ImageLabel is set to Tile instead of Slice or Stretch.

Events

Methods

SetEnableContentImageSizeChangedEvents

Roblox Script Security

Parameters

enabled: boolean

Returns