Thanks for the changes.
I put them in the snippet and extended them to work on transparent PNG images.