Search code examples
pythontkinterzoomingtkinter-canvas

Python img.zoom() allows only integer


I am trying to zoom picture in python but I am able to get only zoom 2x 3x 4x... I am unable to get zoom 1.5x which I need.

    tag1 = tk.PhotoImage(file='assets/tag1.jpg')
    tag1 = tag1.zoom(2)

When I try 1.5 I get an error that the argument can be only integer. I will be thankful for any help or trick on how to overcome this.


Solution

  • Well thanks for help in comments. At the end of the day its solved.

        from PIL import Image
        from PIL import ImageTk
    
        tag1 = Image.open('assets/tag1.jpg')
        tag1 = tag1.resize((tagWidth,tagHeight), Image.ANTIALIAS)
        tag1 = ImageTk.PhotoImage(tag1)