def __screenshot_png(self, func):
"""Helper function that produces the screenshot.
Produces a stitched together screenshot of the current webpage.
Automatically hides and restores Chrome's scrollbars.
Args:
func: A helper function which will be passed the finalized
screenshot. Whatever is returned by `func` is returned
by this function.
Returns:
Whatever is returned by func(screenshot).
"""
self.__scrollbars_hide()
doc_width = self.__document_width
doc_height = self.__document_height
with Image(width=doc_width*2, height=doc_height*2) as screenshot:
for data, rect in self.__iter_screenshots((doc_width, doc_height)):
with Image(blob=base64.b64decode(data),
format='png') as shot:
screenshot.composite(image=shot,
left=rect[LEFT]*2,
top=rect[TOP]*2)
del data
_ret = func(screenshot)
self.__scrollbars_restore()
return _ret
评论列表
文章目录