title: Get color palette from animated GIF with Python PIL
body: <p>I'd like to get the color palette of each frame of an animated GIF (I'm using ColorThief to generate color palette from an image).
  I'm using PIL to save each frame as an image, my problem is that the images of most of the frames  have strange colors, different from the one you see if you open the GIF on a browser. I guess this is because of the way animated GIF are compressed. I tried to convert every image in RGB but this doesn't solve the problem. How can I render each frame with its intended colors?  </p>
  
  <p>To get every frame I'm using the following code:</p>
  
  <pre><code>from PIL import Image, ImageSequence
  
  im = Image.open("phicons/icontech-3-2019-1.gif")
  
  
  index = 1
  for frame in ImageSequence.Iterator(im):
  
      frame.save("phicons/frame%d.gif" % index)
      print(frame)
      index += 1
  </code></pre>
  
  <p>This is the image I'm using for test</p>
  
  <p><a href="https://i.stack.imgur.com/KRUwc.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KRUwc.gif" alt="Animated GIF example"></a> </p>
  
  <p>This is an example of frame with strange colors</p>
  
  <p><a href="https://i.stack.imgur.com/MFzmq.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MFzmq.gif" alt="enter image description here"></a></p>