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