Reputation: 76
So am trying to extract image from browser, first image img.jpg saves perfectly but cropped screensho.jpg saves as blank img.
I am using PIL library for this, image is saving as 180x50 as it should but its blank.
image = Image.open("img.jpg")
rgb_im = image.convert('RGB')
left = location['x'] # 902
top = location['y'] # 1915
right = location['x'] + size['width'] # 902+180
bottom = location['y'] + size['height'] # 1915+50
im = rgb_im.crop((left, top, right, bottom)) # defines crop points
im.save('screenshot.jpg') # saves new cropped image
Could this be the "minimum limits" of pil ?
Upvotes: 0
Views: 547
Reputation: 76
Selenium is not screening entire page by default.
To get around it i used
element = driver.find_elements_by_id('idofelemtineeded')[0]
element_png = element.screenshot_as_png
with open("screen.png", "wb") as file:
file.write(element_png)
Upvotes: 1