Making a forum avatar for alternating backgrounds
Apply the Outer Glow effect to the image using a blend mode of Screen. Set the glow colour to the darker of the two colours. In this case that means the dark purple (#430143).
This has the effect of creating a thin border around the edge of the image. When set against the dark background it will be hardly noticeable. When set against the light background it produces a very delicate blend which offsets the colour change.
In the image above there are two separate layers each filled with one of the two target colours.
Next we use the Save for Web feature to produce a transparent GIF image.