weather scraper improvements
This commit is contained in:
parent
485228e35d
commit
0ca272b563
@ -518,12 +518,12 @@ class Inkycal:
|
|||||||
def _optimize_im(image, threshold=220):
|
def _optimize_im(image, threshold=220):
|
||||||
"""Optimize the image for rendering on ePaper displays"""
|
"""Optimize the image for rendering on ePaper displays"""
|
||||||
|
|
||||||
buffer = numpy.array(image.convert('RGB'))
|
#buffer = numpy.array(image.convert('RGB'))
|
||||||
red, green = buffer[:, :, 0], buffer[:, :, 1]
|
#red, green = buffer[:, :, 0], buffer[:, :, 1]
|
||||||
|
|
||||||
# grey->black
|
# grey->black
|
||||||
buffer[numpy.logical_and(red <= threshold, green <= threshold)] = [0, 0, 0]
|
#buffer[numpy.logical_and(red <= threshold, green <= threshold)] = [0, 0, 0]
|
||||||
image = Image.fromarray(buffer)
|
#image = Image.fromarray(buffer)
|
||||||
return image
|
return image
|
||||||
|
|
||||||
def calibrate(self):
|
def calibrate(self):
|
||||||
|
@ -64,7 +64,7 @@ def get_scraped_weatherforecast_image() -> Image:
|
|||||||
driver.execute_script("arguments[0].style.fontSize = '16px';", html_element)
|
driver.execute_script("arguments[0].style.fontSize = '16px';", html_element)
|
||||||
|
|
||||||
# Save as a screenshot
|
# Save as a screenshot
|
||||||
image_filename = "openweather_scraped.png"
|
image_filename = "/tmp/openweather_scraped.png"
|
||||||
driver.save_screenshot(image_filename)
|
driver.save_screenshot(image_filename)
|
||||||
|
|
||||||
# Close the WebDriver when done
|
# 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.crop((0, 50, my_width, my_height))
|
||||||
#im = im.resize((800, 480), Image.Resampling.LANCZOS)
|
#im = im.resize((800, 480), Image.Resampling.LANCZOS)
|
||||||
#im = im.rotate(90, Image.NEAREST, expand = 1)
|
#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)
|
im.save(image_filename)
|
||||||
return im, im
|
return im, im
|
||||||
|
|
||||||
@ -84,4 +84,4 @@ def main():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(f'running {__name__} in standalone/debug mode')
|
print(f'running {__name__} in standalone/debug mode')
|
||||||
main()
|
main()
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
python3 /home/ubuntu/Inkycal/inkycal/modules/inkycal_openweather_scrape.py
|
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/
|
||||||
|
Loading…
Reference in New Issue
Block a user