HTTPService Json Image url to Roblox Decal within Script

Hi guys!
I have been wanting to with help of the NASA api display random space images in my game, by using HTTTPService getting the json response, but the problem is that roblox only allows roblox urls as the decal url and per script i wont be able to use the url anyways, so is there any roblox feature or maybe even api that could help me?

I currently have no solutions.

(So from what im seeing i would have to make my own api for that?)

1 Like

Unfortunately, there’s really no way to easy achieve this. You would have to upload those images to Roblox.

There are “work arounds” but, they often break TOS.

2 Likes

Image without uploading it to Roblox? I’m not sure if that is possible and it is concerning if it is possible because you can load inappropriate images using HTTP.

1 Like

You can use a png to editable image converter when it becomes available

1 Like

There’s definitely a way to do this, it’d require the use of an external script on your end and it’s somewhat complicated, depending on your knowledge. Essentially how you could even attempt to begin is by establishing your own API on a vercel app or another hosting/web app using django, NextJS routes, etc.

In that API Route you establish, you’d create code to use the Cookie of a Roblox account (this is the account which uploads the item). Then using the account credentials, you’d use the API request info (which you pass through the url) and upload it to Roblox using a fetch/http request.

There’s a devforum post that uses python to do this:

Though I’d recommend using javascript/NextJS if your going to put the route on vercel, since it’s much easier to create an API route.

From their you’d just send a request with the external img url using the roblox open cloud api on roblox, and capture the response with the asset id.

Note this is quite complicated unless you have knowledge in the following:

Roblox Open Cloud API Keys, Creating Web API Routes & Hosting them using another Programming language, and using Roblox’s external and Internal API endpoints.

Currently, I believe this is the only possible way of automatically doing this.

1 Like

Two solutions:

  1. Upload image to Roblox through API in an automated manner. This will have delay and may get the account that created the asset banned/moderated if said asset is inappropriate(so don’t trust user input!)

  2. Use a library to decode the image bytecode so you can fetch the pixels, then use something like frames, gradients, or parts(or basically any other way to visualize pixels, for example the new drawing API) to show the image in-game. This basically bypasses the decal moderation system(since you aren’t uploading anything in order for it to be filtered) so you must ensure said asset is 100% okay to show. I was able to find two such libraries, pngLua and Roblox PNG Library although you may have to ensure said image is a PNG file. Otherwise you may need to find decoders for other formats such as JPEG or create a non-Roblox proxy in between that converts images to the desired format(in this case, PNG). Also you may want to parallelize the process of loading/showing said image in-game and use tricks that reduce lag and client memory.

I think even if the image is okay to show doesn’t mean you are allowed to bypass the filtering and moderation process. I’m pretty sure that is against TOS.

The issue with the second option is it’s quite in efficient, even after optimizing the use of client memory, the end product would still contain hundreds if not a few thousand UI elements, which are loaded in as XML (RBXLX) and XML is quite slow to load, so if you cannot find a way to reduce the amount of elements, the burden the client takes, memory wise is not negociable, unless you sacrifice a large amount of the resolution or find some way to manipulate the properties of these frames more efficiently it’d be at least 5x (Likely exponentially more, if done improperly) less efficient than having the client download the image using the uploaded asset.

So the second option really isn’t an ideal option, nor practical, that adds complexity, and though lua and libraries in lua have the potential to be incredibly fast, other languages like XML, and their run time severely bottleneck Lua’s speed (One of Roblox’s biggest issues), inhibiting the possibility of this being an option for a Roblox game, at least with the current engine.

Actually now that we have the EditableImage class that might not be an issue. Also replication issues can probably be reduced if the client receives the image bytecode instead of the decoded pixels and they decode it themselves on the client. Since most images use formats that compress information(like JPEG and PNG) it will act as a way to send the compressed data to the client.

Although the actual hard part with this is ensuring it works for all image types that the NASA API may return.

Did not know they implemented the editable image class, my bad, I started learning Web Development about 2 years ago and I just recently got back to Roblox for one final project, so I’ve missed quite a lot in terms of new engine features, classes, and api. :joy:

As a person who has created their own external image loading system, some solutions like GradientCanvas made by Boatbomber utilize UIGradients to decrease the number of pixels to render an image significantly while not reducing the quality.

In fact, I made my own API system alongside his rendering module so I could easily request images from the web and almost immediately render them inside the game.
(Newer versions I created can load an image in around 1-2 seconds)

However, I never released the system nor the game publicly (some people even offered me money for it) and I never will, because it is completely against the ToS to bypass Roblox’s systems even if it’s made with goodwill. After all, rules are rules, and for a rule like this, exceptions cannot be made. Your game and possibly your account would get terminated.