I have searched a lot and I found only few solutions (on google and stackoverflow so please don\'t mark this one as a duplicate unless there\'s really duplicate question), b
The third image doesn't look fine, because imagetruecolortopalette($im,true, 255); renders an ugly image:
imagetruecolortopalette($im,true, 255);
Since the second image doesn't look fine, the third can't look beautiful too.
Code:
Original After make truecolortopalette($im,true, 255); Thus..