weather scraper improvements

This commit is contained in:
mrbwburns 2023-11-20 17:29:46 +01:00
parent 485228e35d
commit 0ca272b563
3 changed files with 8 additions and 8 deletions

View File

@ -518,12 +518,12 @@ class Inkycal:
def _optimize_im(image, threshold=220):
"""Optimize the image for rendering on ePaper displays"""
buffer = numpy.array(image.convert('RGB'))
red, green = buffer[:, :, 0], buffer[:, :, 1]
#buffer = numpy.array(image.convert('RGB'))
#red, green = buffer[:, :, 0], buffer[:, :, 1]
# grey->black
buffer[numpy.logical_and(red <= threshold, green <= threshold)] = [0, 0, 0]
image = Image.fromarray(buffer)
#buffer[numpy.logical_and(red <= threshold, green <= threshold)] = [0, 0, 0]
#image = Image.fromarray(buffer)
return image
def calibrate(self):

View File

@ -64,7 +64,7 @@ def get_scraped_weatherforecast_image() -> Image:
driver.execute_script("arguments[0].style.fontSize = '16px';", html_element)
# Save as a screenshot
image_filename = "openweather_scraped.png"
image_filename = "/tmp/openweather_scraped.png"
driver.save_screenshot(image_filename)
# Close the WebDriver when done
@ -75,7 +75,7 @@ def get_scraped_weatherforecast_image() -> Image:
im = im.crop((0, 50, my_width, my_height))
#im = im.resize((800, 480), Image.Resampling.LANCZOS)
#im = im.rotate(90, Image.NEAREST, expand = 1)
#im = ImageEnhance.Contrast(im).enhance(1.3)
im = ImageEnhance.Contrast(im).enhance(1.3)
im.save(image_filename)
return im, im
@ -84,4 +84,4 @@ def main():
if __name__ == '__main__':
print(f'running {__name__} in standalone/debug mode')
main()
main()

View File

@ -1,3 +1,3 @@
#!/bin/sh
python3 /home/ubuntu/Inkycal/inkycal/modules/inkycal_openweather_scrape.py
scp ./openweather_scraped.png inky@10.10.9.10:~/Inkycal/
scp -i /home/ubuntu/.ssh/id_rsa /tmp/openweather_scraped.png inky@10.10.9.10:~/Inkycal/