Below is code-

    # The Python Imaging Library
    # $Id$
    # this demo script creates four windows containing an image and a slider.
    # drag the slider to modify the image.

    from Tkinter import *
    from PIL import Image, ImageTk, ImageEnhance
    import sys

     # enhancer widget

    class Enhance(Frame):
        def __init__(self, master, name, enhancer, lo, hi):
            Frame.__init__(self, master)

            # set up the image

            self.tkim = ImageTk.PhotoImage(image.mode, image.size)
            self.enhancer = enhancer(image)
            #mid = (lo + hi)/2
            self.update('1.0') # normalize

            # image window
            Label(self, image=self.tkim).grid()

            # scale
            s = Scale(self, label=name, orient=HORIZONTAL,
                      from_=lo, to=hi, resolution=0.01,
            #if image == "ip_img.jpg" or image == "not_img.jpg":
             #   s.config(state=DISABLED)

        def update(self, value):
            self.value = eval(value)
  • Now in another code below, I have to write the code that resizes en2.image or another ImageTk.PhotoImage instance that contains a copy of en2.image.

    ####zoom in photoimage instance of en2.image code here

    Label(top, image=en2.tkim).grid(row=0, column=10, columnspan=20, rowspan=20,padx=10, sticky=W+E+N+S)

    im ="zoomin.jpg")
    image = im.resize((80,30),Image.ANTIALIAS)
    photo = ImageTk.PhotoImage(image)
    b=Button(root, image=photo,command=zoomin)


    I've googled and some documents show that there is a zoom method that can be used with photoimage instance but it gives attribute error on the interpreter.
    I tried to change the height and width explicitly using en2.image.height=900 (say), but even thats not working, it does not raise an error, but at the same time, it does not alter the height.

Please tell me a way so that I can resize en2.image.

Edited 4 Years Ago by vy_007

This article has been dead for over six months. Start a new discussion instead.