I am using PIL in python 3 in a program that recolours an image. What it does is, it permanently loops through the pixel values of file.gif (which are returned as integers) and then adds 10 to each of them. I then want it to save the file, which can then be reopened to write to a tkinter label (I've got the rest, but I just need to know about the saving).
Using this code, I have got the program to open the image and display it in the window, then modify the pixel values, but it doesn't change the image displayed.
from tkinter import *
from PIL import Image
from PIL import Image, ImageTk
import time, sys
def col():
global count1,count,pix,x,root
count1+=1
print("("+str(count1)+")")
count=-1
for i in pix:
count+=1
#print(i)
i+=10
pix[count]=i
photo = PhotoImage(file="AI.gif")
x.configure(image=photo)
root.update()
root.after(100, col)
root=Tk()
photo = PhotoImage(file="AI.gif")
x=Label(root, compound="top", image=photo)
x.pack(side="right")
img = Image.open("AI.gif")
pix=list(img.getdata())
width=img.size[0]
height=img.size[1]
img.close()
root.geometry((str(width)+"x"+str(height))+"-0+0")
root.update()
count1=0
col()
root.mainloop()
I am using this image currently:

Edit: @Tadhg McDonald-Jensen I've just run the program with all your suggested edits, but have got this error:
Traceback (most recent call last):
File "C:\Users\name\Desktop\recolour1.py", line 47, in <module>
col()
File "C:\Users\name\Desktop\recolour1.py", line 19, in col
photo.paste(img)
AttributeError: 'PhotoImage' object has no attribute 'paste'
Edit2: here is my latest version of the code that doesn't seem to be modifying the image in the tkinter window:
from tkinter import *
from PIL import Image
from PIL import Image, ImageTk
import time, sys
def col():
global count1,count,pix,x,root,photo
img = Image.open("AI.gif").convert("RGB")
pix=list(img.getdata())
count1+=1
print("("+str(count1)+")")
count=-1
for i in pix:
count+=1
#print(i)
i = tuple(V+100 for V in i)
img.putdata(pix)
photo.paste(img)
root.update()
img.close()
root.after(10, col)
root=Tk()
photo = ImageTk.PhotoImage(file="AI.gif")
x=Label(root, compound="top", image=photo)
x.pack(side="right")
img = Image.open("AI.gif").convert("RGB")
width,height=img.size[0],img.size[1]
img.close()
root.geometry((str(width)+"x"+str(height))+"-0+0")
root.update()
count1=0
col()
root.mainloop()
ImageTk.PhotoImage?ImageTk.PhotoImage, replace the linephoto = PhotoImage("AI.gif")withphoto = ImageTk.PhotoImage("AI.gif")