Python img.zoom() 只允许整数

Python img.zoom() allows only integer

我正在尝试放大图片 python 但我只能缩放 2x 3x 4x...我无法获得我需要的缩放 1.5x。

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

当我尝试 1.5 时出现错误,指出参数只能是整数。 对于如何克服这个问题的任何帮助或技巧,我将不胜感激。

好的,感谢您在评论中的帮助。终于解决了。

    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)