Improved func resizeGif() for better image quality