Rather than returning the image path, it could return the unique hash for the image and the coder can append it to make an image path.
I think this would make the function more versatile.
Script execution time is limited to 5 seconds (and memory use is limited too), even a badly coded script will not be able to run indefinitely.
Perhaps limit the number of creature icons a script can gather in one session, like with avatars. 20 should be sufficient (1kb ?), pagination can be used when the coder needs more.
If the concern is the memory waste from a bad script, consider the additional load from the workaround to manipulate the image as desired. For example, wraping the image in an invisible div given a custom id to be accessed through js, the upside is this would all be done client side.
I admit the sample scripts I made are not optimal because I want them easier for a beginner to understand.
In most scripts I use explicitly declared variables to make the desired functionaly apparent, rather than annoymous parameters even though it is more efficient, I will change this if needed.
If you will keep it to echo the image, I suggest adding a transparent mask to prevent the image being saved easily. Allowing the coder to send an extra parameter for the image attributes as a string (id, class, style etc) would be useful too.
Unfortuantely the save protection cannot be enforced if the function is changed to return only the unique hash.