1
イメージを見つけようとしていて、配列内の最初のイメージとは別のイメージを保存しようとしています。その後、それらの画像をdocxライブラリを使って単語文書にドロップします。現在、以下に試したいくつかの異なるソリューションにもかかわらず、次のエラーが発生しています。ここでは、コードです:Pyautoguiで配列イメージを保存/取得する(AttributeError: 'Image'オブジェクトに 'read'属性がありません)
import sys
import PIL
import pyautogui
import docx
import numpy
def grab_paperclip_images():
'''
This'll look at the documents that're on
the current screen, and create images of
each document with a paperclip. I'll be
testing on an unsorted screen first.
'''
image_array = []
clip_array = find_all_objects("WHITE_PAPERCLIP.png")
for item in clip_array:
coordinates = item[0]+45, item[1], 222, item[3]
image_array.append(pyautogui.screenshot(region=coordinates))
return image_array
doc = docx.Document()
images = grab_paperclip_images()
for image in images:
#print image
#yields: [<PIL.Image.Image image mode=RGB size=222x12 at 0x7CC7770>,etc]
#Tried this - no dice
#img = PIL.Image.open(image)
#doc.add_picture(img)
doc.add_picture(image)
doc.save("testDoc.docx")
私が誤解だ何を知っている、とあなたはコードをよりニシキヘビにするために任意の提案を見れば、よりよいスコープください、など
はいつものように、助けのためのおかげで、誠実に!