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.