title: How to flip an image on canvas when it is edited?
body: <p>I am able to flip an image on the canvas. I am doing it by saving it in a file by using ImageGrab function and rotating that by using ImageOps and placing that on canvas but when the image is edited I mean when objects are rotated or dragged am not able to flip. The drag and rotate part is not there in code.It would be too long if I include it.</p>
  
  <p>Here is my code</p>
  
  <pre><code>from tkinter import *
  from PIL import ImageTk,Image,ImageGrab
  import PIL
  from tkinter import filedialog
  from PIL import ImageOps
  
  
  root = Tk()
  
  def selected1(event):
  
      if clicked1.get()=="flip horizontal":
          x2=root.winfo_rootx()+canvas.winfo_x()
          y2=root.winfo_rooty()+canvas.winfo_y()
          x1=x2+root.winfo_screenwidth()
          y1=y2+root.winfo_screenheight()
          print("save")
          ImageGrab.grab().crop((x2,y2,x1,y1)).save("saver.jpg")
          im = Image.open("saver.jpg")
          im = ImageOps.mirror(im)
          im.save("saver2.jpg")
          canvas.delete('all')
          global img1
          img1=Image.open("saver2.jpg")
          img1=img1.resize((1225,685),Image.ANTIALIAS)
          canvas.img=ImageTk.PhotoImage(img1)
          canvas_img=canvas.create_image(0,0,image=canvas.img,anchor="nw")
  
      if clicked1.get()=="flip vertical":
          x2=root.winfo_rootx()+canvas.winfo_x()
          y2=root.winfo_rooty()+canvas.winfo_y()
          x1=x2+root.winfo_screenwidth()
          y1=y2+root.winfo_screenheight()
          print("save")
          ImageGrab.grab().crop((x2,y2,x1,y1)).save("saver.jpg")
          im = Image.open("saver.jpg")
          im = ImageOps.flip(im)
          im.save("saver1.jpg")
          canvas.delete('all')
          global img2
          img2=Image.open("saver1.jpg")
          img2=img2.resize((1225,685),Image.ANTIALIAS)
          canvas.img=ImageTk.PhotoImage(img2)
          canvas_img=canvas.create_image(0,0,image=canvas.img,anchor="nw")
  
  def selected2(event):
  
      if clicked2.get()=="open file":
          global img
          root.filename=filedialog.askopenfilename(initialdir="/ROBIN",title="select a file",filetypes=(("image files","*.jpg"),("all files","*.*")))
          img=Image.open(root.filename)
          img=img.resize((1225,685),Image.ANTIALIAS)
          canvas.img=ImageTk.PhotoImage(img)
          canvas_img=canvas.create_image(0,0,image=canvas.img,anchor="nw")
  
      if clicked2.get()=="save file":
          x2=root.winfo_rootx()+canvas.winfo_x()
          y2=root.winfo_rooty()+canvas.winfo_y()
          x1=x2+root.winfo_screenwidth()
          y1=y2+root.winfo_screenheight()
          print("save")
          ImageGrab.grab().crop((x2,y2,x1,y1)).save("checker.jpg")
  
      if clicked2.get()=="exit":
          root.quit()
  
  
  
  canvas = Canvas(root)
  canvas.pack(fill=BOTH, expand=1)
  
  rectangles=[]
  
  
  canvas.grid(column=0, row=0, sticky=(N,W,E,S))
  
  root.grid_columnconfigure(0, weight=1)
  root.grid_rowconfigure(0, weight=1)
  
  options1=[
       "select flip",
       "flip horizontal",
       "flip vertical",
  ]
  
  clicked1=StringVar()
  clicked1.set("select flip")
  
  drop1=OptionMenu(root,clicked1,*options1,command=selected1)
  drop1.place(relx=1,x=-1,y=1,anchor=NE)
  
  clicked2=StringVar()
  clicked2.set("select")
  
  options2=[
      "select",
      "open file",
      "save file",
      "exit",
  ]
  
  drop2=OptionMenu(root,clicked2,*options2,command=selected2)
  drop2.place(relx=1,x=-1,y=40,anchor=NE)
  
  root.mainloop()
  </code></pre>