In this example there are 4 shapes drawn on an empty layer, over a solid white background layer. Using the Magic Wand selection tool, I clicked on the empty space on the layer with shapes and then via right-click context menu inverted the selection. Now the selection entirely envelops all 4 shapes, anything unselected is transparent pixels:
From here, I'd like to create a user-defined slice around each separate selection "island", so that each shape is in its own slice, like so (example created manually with help of rulers):
Is there a menu option or a script to do this? Specifically, I want to avoid manually creating layers for each separate shape in cases where there may be tens or hundreds of separate shapes in an image. Basically, I'd like to automate slicing of what can fit under the definition of a "sprite sheet".