Add a way to get dominant colors from ImageLabels/ViewportFrames

As a Roblox developer, it is currently impossible to get the dominant colors from an image/viewport.

For example, if an API was made to get the dominant colors of a picture, it would make it way easier to create UI for certain situations. Here are examples of one use case. (Portrait of a Roblox Character)

Click to expand.

Also, here is an example of a site that gets the dominant colors from a picture. A similar thing could be implemented in Roblox, for example, a function :GetDominantColors(colorAmount: number) could be added to ViewportFrames and ImageLabels. It would be also great if developers could pass the number of dominant colors they would like to get. (In the image below I have chosen 5 colors to be returned on the site.)

6 Likes

I think that an API to get individual pixel data (such as color) on-screen/from an image could better suit this for more flexibility and it would cover more use cases.

I’ve heard there could be privacy concerns with something like this, but I could find this more useful alone, and it would allow us to make functions used for getting common colors of an image or in the area of a viewport, say if I wanted to change black text with no background to white in dark environments.

6 Likes

I have actually designed a module that has the capabilities to grab Color3 pixel values from a PNG image file from your computer. It also works in game too and doesn’t use any third party tools or HTTP services.

local MiddlePixel = CanvasDraw.GetPixelFromImage(
    ImageData, 
    Vector.new(50, 50)
)

This may come in handy for something like this

2 Likes