What is the best way to get an image id from decal id with a script?

So basically I want to make a script that players can customize particle with decal id my main problem is what should I do or use to get image id from decal id?

I thought it was impossible until I found this, yes it is possible and is the only way to get an image id from a decal id.