I am trying to use Python to batch edit .png files using the Pillow library. This is my first script using python and as such it is likely that there will be many errors and / or bad programming practices.
Here is my current code:
from PIL import Image from PIL import ImageDraw from os.path import basename import os, sys path = "D:\Pokemon Game\Pokemon Eggs\Import" dirs = os.listdir( path ) box = (2,1,30,31) moveup = (0, -3, -7, -11, -15, -19, -15, -9, -5, 2, 12, 14, 16, 17, 12, 8, 4, 0, -7, -13, -19, -11, -7, -5, -3) topspace = (36, 38, 42, 46, 50, 55, 50, 44, 40, 34, 24, 22, 20, 18, 24, 28, 32, 36, 42, 48, 55, 46, 42, 40, 38) bottomspace = (0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 10, 14, 17, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0) Imagesizes = ((56, 60), (56, 58), (56, 54), (56, 50), (56, 46), (56, 41), (56, 46), (56, 52), (56, 56), (56, 60), (56, 66), (56, 64), (56, 62), (56, 60), (56, 60), (56, 60), (56, 60), (56, 60), (56, 54), (56, 48), (56, 41), (56, 50), (56, 54), (56, 56), (56, 58)) for file in dirs:
My goal is to make the image of the inanimate egg end up looking like the animated image shown below:


The problems with my code are that, firstly, the entire section between line 35 and line 47 leads to a loss of transparency (this is due to line 47). And I donโt know how to convert the list (image) to an animated GIF.