imageopen = Image.open("logo.png")
imageopen = imageopen.resize((1000,1000), Image.LANCZOS)
frame = ctk.CTkFrame(master=root)
frame.pack(pady=20, padx=60, fill="both", expand="True")
image = ctk.CTkImage(imageopen)
label = ctk.CTkLabel(master=frame, image=image, text="", height=200)
label.pack(pady=12, padx=10)
因此,当我使用 customtkinter 开发 UI 时,我添加了一个包含图像“logo.png”的标签。但是当我运行代码时,图像非常小。所以我尝试用 Pillow 的 resize() 函数调整它的大小,但不起作用。这是我的代码,但是图像仍然很小。
我尝试将“LANCZOS”更改为“ANTIALIAS”,但不起作用
您可以安装 Pillow 库(pip install Pillow)来执行此操作
示例:
from PIL import Image
imageopen = Image.open("logo.png")
resized_image = imageopen.resize((1000, 1000), Image.LANCZOS)
# Now you can use the resized image in your UI