Skip to main content
ubuntuask.com

Back to all posts

How to Control the Size Of A Picture Using Tkinter?

Published on
4 min read
How to Control the Size Of A Picture Using Tkinter? image

Best Tkinter Image Resizing Tools to Buy in October 2025

1 Accurasee Artist 11 Inch Proportional Divider - Upgraded Drawing Supplies & Drafting Tools - Adjustable Caliper & Subject Dividers for Art Drawing Tools

Accurasee Artist 11 Inch Proportional Divider - Upgraded Drawing Supplies & Drafting Tools - Adjustable Caliper & Subject Dividers for Art Drawing Tools

  • VERSATILE TOOL: PERFECT FOR ARTISTS; REPLACES COMPASSES AND PROJECTORS.
  • EASY SCALING: LOCKING MECHANISM ENSURES CONSISTENT MEASUREMENTS.
  • DURABLE DESIGN: MADE FROM STURDY PLASTIC FOR LONG-LASTING PRECISION.
BUY & SAVE
$9.99
Accurasee Artist 11 Inch Proportional Divider - Upgraded Drawing Supplies & Drafting Tools - Adjustable Caliper & Subject Dividers for Art Drawing Tools
2 Westcott 5" Proportional Scale, White (PS-69)

Westcott 5" Proportional Scale, White (PS-69)

  • RESIZE IMAGES ACCURATELY WITH OUR 5-INCH PROPORTIONAL WHEEL!
  • CLEAR MARKINGS FOR PRECISE MEASUREMENTS-EASY TO READ AND USE.
  • PERFECT FOR ARTISTS, DESIGNERS, ENGINEERS, AND STUDENTS ALIKE!
BUY & SAVE
$5.65
Westcott 5" Proportional Scale, White (PS-69)
3 2Pcs Box Scoring Tool, Box Resizer Maker with Scoring Wheel, Stainless Steel Tracing Wheel, Professional Stitch Marking Spacer with Plastic Handle for Tracing Paper, Cardboard, Carton, Leather Craft

2Pcs Box Scoring Tool, Box Resizer Maker with Scoring Wheel, Stainless Steel Tracing Wheel, Professional Stitch Marking Spacer with Plastic Handle for Tracing Paper, Cardboard, Carton, Leather Craft

  • CREATE CUSTOM BOXES EFFORTLESSLY WITH PRECISION PERFORATION.
  • ERGONOMIC HANDLE DESIGN ENSURES STABILITY AND COMFORT WHILE USING.
  • DURABLE CONSTRUCTION GUARANTEES LONG-TERM PERFORMANCE AND RELIABILITY.
BUY & SAVE
$11.99
2Pcs Box Scoring Tool, Box Resizer Maker with Scoring Wheel, Stainless Steel Tracing Wheel, Professional Stitch Marking Spacer with Plastic Handle for Tracing Paper, Cardboard, Carton, Leather Craft
4 Ring Size Adjuster for Loose Rings, 8 Sizes Invisible Ring Guards and Spacers, Fits Ring Widths 1-10mm, Ring Resizer for Men's and Women's Jewelry

Ring Size Adjuster for Loose Rings, 8 Sizes Invisible Ring Guards and Spacers, Fits Ring Widths 1-10mm, Ring Resizer for Men's and Women's Jewelry

  • ALL-DAY COMFORT WITH SOFT SILICONE THAT HUGS YOUR FINGER SEAMLESSLY.

  • 8 VERSATILE SIZES FIT RINGS FROM 1-10MM FOR THE PERFECT SNUG FIT.

  • INVISIBLE DESIGN RETAINS RING BEAUTY WHILE PREVENTING SLIPPING OR SPINNING.

BUY & SAVE
$5.86
Ring Size Adjuster for Loose Rings, 8 Sizes Invisible Ring Guards and Spacers, Fits Ring Widths 1-10mm, Ring Resizer for Men's and Women's Jewelry
5 Custom Signature Stamp - Self Inking Personalized Signature Stamp | Great for Signing Documents | Stamp Will Provide Thousands of Impressions

Custom Signature Stamp - Self Inking Personalized Signature Stamp | Great for Signing Documents | Stamp Will Provide Thousands of Impressions

  • CUSTOMIZABLE SIZE FOR YOUR UNIQUE SIGNATURE-PERFECT FIT EVERY TIME!
  • IDEAL FOR SIGNING DOCUMENTS QUICKLY AND PROFESSIONALLY.
  • QUALITY CRAFTSMANSHIP-PROUDLY MADE IN THE USA!
BUY & SAVE
$18.99
Custom Signature Stamp - Self Inking Personalized Signature Stamp | Great for Signing Documents | Stamp Will Provide Thousands of Impressions
6 The Photography Deck - Shooting & Editing Cheat Sheet Cards - Essential Guide & Quick Tips

The Photography Deck - Shooting & Editing Cheat Sheet Cards - Essential Guide & Quick Tips

  • MASTER PHOTOGRAPHY SKILLS WITH EASY-TO-USE CARD DECKS!
  • COMPACT AND TRAVEL-FRIENDLY: PERFECT FOR ON-THE-GO PHOTOGRAPHERS.
  • UNIQUE PHOTOGRAPHY GIFT FOR ENTHUSIASTS OF ALL SKILL LEVELS!
BUY & SAVE
$39.49
The Photography Deck - Shooting & Editing Cheat Sheet Cards - Essential Guide & Quick Tips
7 PEVART Watercolor Tin Palette, Metal Empty Paint Case with 52 PCS Empty Half Pans and a Water color Pen Suitable for DIY Travel Watercolor Palette, Acrylic and Oil Painting

PEVART Watercolor Tin Palette, Metal Empty Paint Case with 52 PCS Empty Half Pans and a Water color Pen Suitable for DIY Travel Watercolor Palette, Acrylic and Oil Painting

  • CUSTOMIZABLE PALETTE WITH 52 REMOVABLE HALF PANS FOR EASY MIXING!

  • DURABLE, LIGHTWEIGHT METAL DESIGN PERFECT FOR OUTDOOR PAINTING!

  • INCLUDES WATER BRUSH & FABRIC BAG FOR CONVENIENT TRAVEL STORAGE!

BUY & SAVE
$17.20
PEVART Watercolor Tin Palette, Metal Empty Paint Case with 52 PCS Empty Half Pans and a Water color Pen Suitable for DIY Travel Watercolor Palette, Acrylic and Oil Painting
8 3D Printing and Maker Lab for Kids: Create Amazing Projects with CAD Design and STEAM Ideas (Volume 22)

3D Printing and Maker Lab for Kids: Create Amazing Projects with CAD Design and STEAM Ideas (Volume 22)

BUY & SAVE
$12.59 $24.99
Save 50%
3D Printing and Maker Lab for Kids: Create Amazing Projects with CAD Design and STEAM Ideas (Volume 22)
9 Phomemo Label Maker Machine, D30 Portable Handheld Bluetooth Mini Label Printer, Multiple Templates Smartphone Thermal Small Label Maker for Kids School Items, Classroom Teacher Supplies, Easy to Use

Phomemo Label Maker Machine, D30 Portable Handheld Bluetooth Mini Label Printer, Multiple Templates Smartphone Thermal Small Label Maker for Kids School Items, Classroom Teacher Supplies, Easy to Use

  • COMPACT & LIGHTWEIGHT: HALF THE SIZE OF TRADITIONAL LABEL MAKERS.
  • INKLESS PRINTING: SAVE ON COSTS WITH AFFORDABLE THERMAL LABEL TAPES.
  • CREATIVE & FUN: 1000+ TEMPLATES FOR EFFORTLESS LABEL DESIGN!
BUY & SAVE
$27.79 $29.99
Save 7%
Phomemo Label Maker Machine, D30 Portable Handheld Bluetooth Mini Label Printer, Multiple Templates Smartphone Thermal Small Label Maker for Kids School Items, Classroom Teacher Supplies, Easy to Use
+
ONE MORE?

To control the size of a picture using tkinter, you can use the PhotoImage class to load the image and then use the subsample method to resize it. You can specify the width and height you want the image to be by dividing the original dimensions by a certain factor.

For example, if you have a PhotoImage object called image and you want to resize it to half of its original size, you can use the following code:

image = image.subsample(2, 2)

This code will resize the image to half of its original width and height. You can adjust the factor to resize the image to your desired dimensions. Additionally, you can use the Label widget to display the resized image on your tkinter window.

How to resize an image by dragging the corners in tkinter?

In order to resize an image by dragging the corners in tkinter, you can use the following steps:

  1. Load the image that you want to resize using the PIL library.
  2. Create a tkinter Canvas widget to display the image.
  3. Bind mouse events to the Canvas widget to track when the user clicks and drags the corners of the image.
  4. Calculate the new size of the image based on the distance that the user has dragged the corners.
  5. Resize the image and update the Canvas widget to display the resized image.

Here's an example code snippet to demonstrate this:

from tkinter import * from PIL import Image, ImageTk

class ResizableImage: def __init__(self, root, image_path): self.root = root self.image_path = image_path

    self.image = Image.open(self.image\_path)
    self.image\_tk = ImageTk.PhotoImage(self.image)
    
    self.canvas = Canvas(root, width=self.image.width, height=self.image.height)
    self.canvas.pack()
    
    self.canvas.create\_image(0, 0, anchor=NW, image=self.image\_tk)
    
    self.canvas.bind("<Button-1>", self.on\_click)
    self.canvas.bind("<B1-Motion>", self.on\_drag)
    
    self.dragging = False
    self.start\_x = 0
    self.start\_y = 0
    
def on\_click(self, event):
    self.start\_x = event.x
    self.start\_y = event.y
    self.dragging = True
    
def on\_drag(self, event):
    if self.dragging:
        new\_width = self.image.width + (event.x - self.start\_x)
        new\_height = self.image.height + (event.y - self.start\_y)
        self.image = self.image.resize((new\_width, new\_height))
        self.image\_tk = ImageTk.PhotoImage(self.image)
        self.canvas.config(width=new\_width, height=new\_height)
        self.canvas.create\_image(0, 0, anchor=NW, image=self.image\_tk)
    
        self.start\_x = event.x
        self.start\_y = event.y

root = Tk() image_path = "path/to/your/image.jpg" app = ResizableImage(root, image_path) root.mainloop()

This code creates a resizable image window using tkinter and allows the user to click and drag the corners to resize the image.

How to maintain image quality when resizing in tkinter?

One way to maintain image quality when resizing in tkinter is to use the Image.ANTIALIAS filter when resizing the image. This filter will help to smooth out the image and reduce jagged edges that can occur when scaling down an image.

Here is an example of how to resize an image while maintaining quality with the Image.ANTIALIAS filter:

from PIL import Image, ImageTk import tkinter as tk

def resize_image(image, width, height): return image.resize((width, height), Image.ANTIALIAS)

Load your image

original_image = Image.open("image.jpg")

Resize the image

resized_image = resize_image(original_image, 200, 200)

Display the resized image in a tkinter window

root = tk.Tk() tk_image = ImageTk.PhotoImage(resized_image) label = tk.Label(root, image=tk_image) label.pack()

root.mainloop()

By using the Image.ANTIALIAS filter when resizing images in tkinter, you can maintain image quality and ensure that your images look crisp and clear even after resizing.

How to adjust the size of an image within a tkinter window?

You can adjust the size of an image within a tkinter window by using the subsample or zoom methods of the Image class in the PIL (Pillow) module. Here is an example code snippet that demonstrates how to resize an image within a tkinter window:

import tkinter as tk from PIL import Image, ImageTk

Create a tkinter window

root = tk.Tk()

Open an image file

image = Image.open("example.png")

Resize the image

image = image.resize((200, 200), Image.ANTIALIAS) # adjust the size as needed

Convert the image to a PhotoImage object

photo = ImageTk.PhotoImage(image)

Display the image in a tkinter label

label = tk.Label(root, image=photo) label.pack()

Run the tkinter main loop

root.mainloop()

In this code snippet, the resize method is used to adjust the size of the image to (200, 200) pixels. You can change the size by modifying the arguments passed to the resize method. The ANTIALIAS argument ensures that the resized image maintains its visual quality. Finally, the resized image is displayed in a tkinter window using a Label widget.

Remember to replace "example.png" with the file path of your own image.