python 打开图片

import cv2
from PIL import Image


def print_image_to_console(image_path: str):
    """调用系统打开图片
    Args:
        image_path (str): _description_
    """
    image = Image.open(image_path)
    image.show()


def print_image_to_console2(image_path: str):
    """调用自带的窗口打开图片

    Args:
        image_path (str): _description_
    """
    image = cv2.imread(image_path, cv2.IMREAD_COLOR)
    cv2.imshow("Image", image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


if __name__ == "__main__":
    print_image_to_console2("assest\icon.png")
    print("测试")

在Python中,有一些库可以将图片打印到控制台。其中,最常用的库是 Pillow(Python Imaging Library,简称PIL)和 OpenCV(Open Source Computer Vision Library)。

可以使用pip install pillow命令进行安装。

可以使用pip install opencv-python命令进行安装。

THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容