How to resize a Splash Screen Image using Tkinter?
<p>I am working on a game for a school project and as a part of it a Splash Screen is to load to simulate the 'loading' of the game. I have the code and it does bring up the image, but what I want it to do is bring up the defined .gif file onto the screen. Here is the code:</p>

<pre><code>import tkinter as tk
root = tk.Tk()
root.overrideredirect(True)
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (width*1, height*1, width*0, height*0))
image_file = "example.gif"
image = tk.PhotoImage(file=image_file)
canvas = tk.Canvas(root, height=height*1, width=width*1, bg="darkgrey")
canvas.create_image(width*1/2, height*1/2, image=image)
canvas.pack()
root.after(5000, root.destroy)
root.mainloop()
</code></pre>

<p>My only issue is that because the image is larger than the screen it does not fit as a whole image. How can I resize the image using this code so that any .gif image fits on the screen?</p>

<p>P.S. Please do not make any real drastic changes to the code as this does what I want, value changes are ok.</p>

<p>I recommend you to use <a href="http://www.pythonware.com/products/pil/" rel="nofollow">PIL</a>.<br>
Here is the code:  </p>

<pre><code>from PIL import Image, ImageTk
import Tkinter as tk

root = tk.Tk()
root.overrideredirect(True)
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (width*1, height*1, width*0, height*0))
image = Image.open(image_path)
image = image.resize((width, height), Image.ANTIALIAS)
image = ImageTk.PhotoImage(image)
canvas = tk.Canvas(root, height=height*1, width=width*1, bg="darkgrey")
canvas.create_image(width*1/2, height*1/2, image=image)
canvas.pack()
root.after(5000, root.destroy)
root.mainloop()
</code></pre>

<p>You get the width and height from:</p>

<pre><code>width = root.winfo_screenwidth()
height = root.winfo_screenheight()
</code></pre>

<p>then call <strong>resize()</strong></p>

<p>If you still want to use PhotoImage, you can try <strong>zoom(x, y)</strong> and <strong>subsample(x, y)</strong>. Here is the <a href="http://epydoc.sourceforge.net/stdlib/Tkinter.PhotoImage-class.html" rel="nofollow">doc</a>. By the way, It's not work on my computer...(python2.7 + win7)</p>

python canvas tkinter tkinter-canvas