Decal2image - Decal IDs to image IDs

decal2image is a bite-sized module for getting image IDs from decal IDs. This solves the problem of getting image IDs from decal IDs in an extremely reliable way with virtually no downsides.
You can find the module here. If you’d like to take a peek at the source code or make a contribution, the GitHub repo is here.

Example usage
-- Make sure that HttpService is enabled
local d2i = require(7062490293) -- Returns ID or false if it fails to retrieve the ID

print(d2i(1522361034)) --> 1522361030

If you’d like to know about how it works, you can see that below.

How it works

The module uses the Roblox Asset Delivery API at its core. In case you don’t know, the Asset Delivery API serves some core info to assets. That includes the XML of the asset. All assets have an XML file associated to them that contains some important in-game values. For decals, the XML file will always include the asset URL (not the library URL) of the decal’s image. The key thing is that the asset URL contains the image ID. decal2image extracts the asset URL and then splices it so that it only returns the image ID.

If you have any feedback, let me know! Keep in mind that this is one of my first open-source projects and my first DevForum post, so please be a little gentle.

16 Likes

Orr you could just get the image id from a Decal or Texture instance or just use those instances instead. I don’t see why you need a whole module while more simple and alternative ways (that don’t require httpservice to be on) exist.

This is useful if you need to get the decal ID in real time. Roblox doesn’t automatically convert it if you set the property via code.

3 Likes

When would you actually need to set it in real time?? If anything you could do this faster without using this module by just putting the id into a decal or texture first and getting the id from there.

There are many reasons. Off the top of my head:

  • Group Recruiting Plaza allows players to have custom decals for stands
  • Spray paint decal onto surfaces
  • Custom in-game ads
  • Custom in-game clan logo

Anything that deals with players being able to have custom images in-game

5 Likes

The main point of the module is displaying user-input as an image. There are a lot of times when you need to do that, but cannot because of decal IDs not being able to be displayed. I created this because I failed to find a reliable solution that didn’t have a major downside.

Module has been slightly updated (thank you “person-person” for your pull request).