Inverse Transparency of a PNG
I can suggest a destructive method, as I've tried using masks but I couldn't get it to work.
Begin with a large canvas size, i.e. the largest possible display size, and 300 PPI.
Set the background to be consistent with the background you're using in your app.
Create the shape you want to be able to colour variably.
Magic Wandtool with zero
Toleranceto capture the shape of the image.
Rasterize the background and press delete.
You should end up with a cut out of the shape.
Resize the image to the sizes you need it at.
You will need to use various thumbnail sizes with this method if you need to display it at largely varying sizes, as it's not vector based it won't scale that beautifully outside of a GD program.
You can then change the background colour of the image container dynamically with your script.
A better, but far more time consuming method would be to create a vector based outline.