import os from os import remove from PIL import Image diskPath = "D:/_FACTORIO/circuit-connector-module/" inputFolder = "03_Ae/Ae-OUTPUT/Shiftings/" outputFolder = "04_Python-spritesheeterInput/Shiftings/" entityName = "_ENTITY-shiftings-ACCUMULATOR" def filterStuff(inputImage, frameNumber): shiftingImage = diskPath + inputFolder + inputImage+ "/" + inputImage + frameNumber + ".png" i = Image.open(shiftingImage) newImageRed = Image.new("RGBA", (i.width,i.height), color=(0,0,0,0)) newImageBlue = Image.new("RGBA", (i.width,i.height), color=(0,0,0,0)) for x in range(0, i.width): for y in range(0, i.height): pix = i.getpixel((x,y)) if pix[0] == 255: newImageRed.putpixel((x,y),pix) if pix[2] == 255: newImageBlue.putpixel((x,y),pix) os.makedirs(diskPath + outputFolder + inputImage + frameNumber + "/" , exist_ok = True) newImageRed.save(diskPath + outputFolder + inputImage + frameNumber + "/" + inputImage + frameNumber + "_boxShifting.png") newImageBlue.save(diskPath + outputFolder + inputImage + frameNumber + "/" + inputImage + frameNumber + "_shadowShifting.png") def run(): filterStuff("_ENTITY-shiftings-ACCUMULATOR", "_000") import traceback try: run() except Exception as e: traceback.print_exc() input("Press enter to continue...")