title: Resizing Image and fit it to the Canvas size
body: <p>Can anyone help me to resize the image using ImageTk?</p>
  <p>I have a canvas and I will put pictures there.</p>
  <p>I have different kinds of pictures = different sizes for all pictures</p>
  <p>And when I attach the picture (just one) in the canvas, I want the picture's size to resize so that it will fit in the canvas and it will still maintain its proportion.</p>
  <p>Please help me! I am new in PIL, Tkinter,and Python.</p>
  <p>Update:</p>
  <p>I tried using <code>thumbnail</code> under <code>Image</code> but in resizing:</p>
  <pre><code>self.image.thumbnail(self.picsize,Image.ANTIALIAS)
  </code></pre>
  <p>the image is not fitting the canvas size and if the image is longer/wider than the canvas, it is just cut. (Not resizing to fit into the canvas)</p>
  <hr />
  <p>Code:</p>
  <pre><code>from PIL import ImageTk
  from Tkinter import *
  import os,tkFileDialog,Image
  
  picsize = 250,250 # I want to set this so that it will fit in the self.imagecanvas | Every images attached will share same Size
  imagepath = &quot;Default_ProPic.jpg&quot;
  class GUI():
      global picsize
      def display(self):
          self.canvas = Canvas(width=1200,height=700)
          self.canvas.pack()
      
          self.imagecanvas = Canvas(self.canvas,width=400,height=400)
          self.imagecanvas.place(x=980,y=180)
          self.image = Image.open(imagepath)
          self.image.thumbnail(picsize,Image.ANTIALIAS)
          self.newimage = ImageTk.PhotoImage(self.image)
          self.profile_picture=self.imagecanvas.create_image(0,0,anchor = NW,image=self.newimage)
      
          attachbutton = Button(self.canvas,text=&quot;       Profile Pic       &quot;,command=lambda:self.attachpic())
          attachbutton.place(x=1030,y=320)
      
          mainloop()
  
      def attachpic(self):
          global picsize
          attachphoto = tkFileDialog.askopenfilename(title=&quot;Attach photo&quot;)
          self.image = Image.open(attachphoto)
          self.image.thumbnail(picsize,Image.ANTIALIAS)
          self.newimage = ImageTk.PhotoImage(self.image)
          self.imagecanvas.itemconfigure(self.profile_picture, image=self.newimage)
      
  GUI = GUI()
  GUI.display()
  </code></pre>
  <hr />
  <p>Picture used above: <img src="https://i.stack.imgur.com/5GpZm.jpg" alt="enter image description here" /></p>