屏幕上的图像?

时间:2017-11-26 01:13:22

标签: python python-imaging-library screenshot

我正在python中创建一个程序,用于确定屏幕上是否存在图像以及是否这样说。目前我无法正常工作,不确定出了什么问题

import time
import os
from PIL import ImageGrab
import base64

clear = lambda: os.system('cls')

im = ImageGrab.grab()
im.save('screenshot.png')

time.sleep(1)

with open("screenshot.png", "rb") as imageFile:
    str = base64.b64encode(imageFile.read())
    print str
img1 = str

with open("test.PNG", "rb") as imageFile:
    str = base64.b64encode(imageFile.read())
    print str
img2 = str  

clear()

if img1 in img2:
    print("images are the same")
else:
    print("images are not the same")

print("This line will be printed.")
time.sleep(5)

0 个答案:

没有答案