From 4a197cc24875266861821b2d05d2b8cb51e65a74 Mon Sep 17 00:00:00 2001 From: PAlexanderFranklin Date: Thu, 1 Aug 2024 21:04:31 -0700 Subject: [PATCH] Add some randomization to further obscure text --- src/screenmonitor.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/screenmonitor.py b/src/screenmonitor.py index feaba23..213e94f 100644 --- a/src/screenmonitor.py +++ b/src/screenmonitor.py @@ -19,6 +19,28 @@ def capture_screenshot(): # Apply blur blurred_screenshot = screenshot.filter(ImageFilter.GaussianBlur(10)) + # Randomly turn 10% of the pixels black + pixels = blurred_screenshot.load() + width, height = blurred_screenshot.size + total_pixels = width * height + black_pixels_count = int(total_pixels * 0.1) + neighbor_copy_pixels_count = int(total_pixels * 0.01) + + for _ in range(black_pixels_count): + x = random.randint(0, width - 1) + y = random.randint(0, height - 1) + pixels[x, y] = (0, 0, 0) + + # Make 1% of the pixels copy themselves to their 8 neighbors + for _ in range(neighbor_copy_pixels_count): + x = random.randint(0, width - 1) + y = random.randint(0, height - 1) + original_color = pixels[x, y] + for dx in [-1, 0, 1]: + for dy in [-1, 0, 1]: + if 0 <= x + dx < width and 0 <= y + dy < height: + pixels[x + dx, y + dy] = original_color + # Compress and save timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = os.path.join(output_dir, f"screenshot_{timestamp}.jpeg")