我正在抓取一个通过将信息显示为图像来保护的网页,以免被抓取。当我导入格式.gif
为它发送错误的图像时。我试图找到一种方法将导入的图像转换为另一种格式,如 png,但我没有成功。
from PIL import Image
import pytesseract
import cv2
import imutils
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
url = "url.gif"
rawimge = Image.open(urllib.request.urlopen(url))
image = imutils.resize(rawimge, width=400)
blur = cv2.GaussianBlur(image, (7,7), 0)
thresh = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
result = 255 - thresh
phone = pytesseract.image_to_string(result, lang='eng',config='--psm 6')
print(phone)
cv2.imshow('thresh', thresh)
cv2.imshow('result', result)
cv2.waitKey()
错误:
AttributeError: 'GifImageFile' object has no attribute 'shape'