From 75e4d0b78651f2e17fd19e257ae2e82cf155b5cf Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Fri, 27 Mar 2026 16:38:55 -0500 Subject: [PATCH] Replace simulator sliders with WYSIWYG crop tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The simulator now shows the full source image with a draggable crop window overlay. Drag the frame over the photo to position the crop — dimmed regions show what gets cut. The dithered e-paper preview renders live in the side panel. Mode toggle: "Fill" (zoom with draggable pan) vs "Fit" (letterbox). Save persists per-image settings used when the ESP32 fetches the photo. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/server.py | 372 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 260 insertions(+), 112 deletions(-) diff --git a/server/server.py b/server/server.py index fcfce51..a499727 100644 --- a/server/server.py +++ b/server/server.py @@ -393,6 +393,24 @@ def preview_random(): return preview_photo(chosen.name) +@app.route("/api/photos//geometry") +def photo_geometry(name: str): + """Return source image dimensions and the computed crop/fit geometry.""" + fname = secure_filename(name) + path = PHOTOS_DIR / fname + if not path.exists(): + return jsonify({"error": "not found"}), 404 + img = Image.open(path) + lw, lh = get_logical_dimensions() + return jsonify({ + "source_width": img.width, + "source_height": img.height, + "logical_width": lw, + "logical_height": lh, + "logical_aspect": lw / lh, + }) + + @app.route("/simulate/") def simulate_page(name: str): fname = secure_filename(name) @@ -401,8 +419,10 @@ def simulate_page(name: str): return "", 404 settings = get_image_settings(fname) orientation = frame_settings.get("orientation", "landscape") + lw, lh = get_logical_dimensions() return render_template_string(SIMULATE_UI, photo_name=fname, - settings=settings, orientation=orientation) + settings=settings, orientation=orientation, + logical_w=lw, logical_h=lh) SIMULATE_UI = """ @@ -410,156 +430,284 @@ SIMULATE_UI = """ -E-Paper Simulator — {{ photo_name }} +{{ photo_name }} — Frame Preview -

E-Paper Display Simulator

-
- E-paper preview +
+ ← Gallery + {{ photo_name }} +
+ +
+ +
-
-

Display Settings

- -
- - -
- -
-
- - - {{ '%.0f' % (settings.pan_x * 100) }}% -
-
- - - {{ '%.0f' % (settings.pan_y * 100) }}% -
-
- -
- - - Rendering... +
+
+
+ +
+
+
+
+
- ← Back to gallery +
+ E-Paper Preview +
+ +
+ +
+