0

Below is en2.py 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,
                      command=self.update)
            #if image == "ip_img.jpg" or image == "not_img.jpg":
             #   s.config(state=DISABLED)
            s.set(self.value)
            s.grid(row=0,column=0)

        def update(self, value):
            self.value = eval(value)
            tkim.paste(self.enhancer.enhance(self.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 = Image.open("zoomin.jpg")
    image = im.resize((80,30),Image.ANTIALIAS)
    photo = ImageTk.PhotoImage(image)
    b=Button(root, image=photo,command=zoomin)
    b.grid(row=5,column=0)

    root.mainloop()

    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 by vy_007

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by pyTony
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.