For example, I create an image, set white as the transparent color, and end up making something like this:

Obviously, the inner small square would be transparent, as would the outside of the black square. What I'm looking for is a way to get everything from the outer edge of the black square in--including the transparent square--as an outline, so I can fill it.
I can't just use coordinates because the images will be mixtures of other pictures from imagecreatefromgif() calls. I just need a way to fill it all in, without filling in the very-outer border.
Is this possible? If so, how?
-IMP