import numpy as np
from PIL import Image, ImageSequence
img = Image.open('test.gif')
frames = np.array([np.array(frame.copy().convert('RGB').getdata(),dtype=np.uint8).reshape(frame.size[1],frame.size[0],3) for frame in ImageSequence.Iterator(img)])
вывод:
(frame_num * frame_width * frame_height * 3 (RGB))
[array([[[ 0, 0, 0],
[ 20, 0, 0],
[ 40, 0, 0],
[ 60, 0, 0],
[ 80, 0, 0]],
[[ 0, 20, 0],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[ 0, 40, 0],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[ 0, 60, 0],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[ 0, 80, 0],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]]], dtype=uint8),
array([[[ 0, 0, 20],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]]], dtype=uint8),
array([[[ 0, 0, 40],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]]], dtype=uint8),
array([[[ 0, 0, 60],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],
[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]]], dtype=uint8)]