I had some issues with transparent PNG images causing some strange effects when resized and saved with Python's PIL Image library.
As you can see, those jarring effects are hard to ignore.
The issue was I was ignoring the alpha channel during conversion and PIL didn't quite know what to do with it.
It is a bit more work, but the results speak for themselves. Even the GIF image quality was improved after using this method!
I found a better way of colouring the images which had NO loss in quality (updated code above)
You can easily see which one is rendered with the new code as the difference is quite noticeable.
There was a bug which replaced the whole pixel with white, which is wrong because it could be any other colour with transparency < 255.
(Here's the old code if anyone was wondering)