Explorar el Código

adapt capture script

Richard Köhl hace 1 año
padre
commit
66a20a59ef
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7 5
      capture.py

+ 7 - 5
capture.py

@@ -1,18 +1,20 @@
 import datetime
+import io
+from PIL import Image
 from ppadb.client import Client as AdbClient
 
 client = AdbClient(host="127.0.0.1", port=5037)
 device = client.device("192.168.178.32:5555")
 
 def save_screenshot():
-  # Take a screenshot
   result = device.screencap()
 
   timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
-  filename = f"fights/{timestamp}.png"
+  image = Image.open(io.BytesIO(result))
+  jpeg_filename = f"/mnt/t/nextcloud/InstantUpload/Herowars/{timestamp}.jpg"
 
-  # Save the screenshot to a file
-  with open(filename, "wb") as fp:
-      fp.write(result)
+  image = image.convert('RGB')  # Convert to RGB mode for JPEG
+  with open(jpeg_filename, "wb") as fp:
+    image.save(fp, format='JPEG', quality=85)  # Adjust quality as needed
 
 save_screenshot()