Skip to content

✨ Add Snapshot Capture to the OpenLayers Viewer - #1184

Draft
Demir-B wants to merge 14 commits into
developfrom
feature/openlayers-snapshot
Draft

Demir-B wants to merge 14 commits into
developfrom
feature/openlayers-snapshot

Conversation

@Demir-B

@Demir-B Demir-B commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Added snapshot capture to the experimental OpenLayers viewer.

  • added a snapshot button to save the current viewer as a PNG
  • snapshots include the current slide and visible overlays
  • overlay visibility, opacity and order are kept in the saved image
  • the scale bar can also be included in snapshots
  • added a loading indicator while slides, overlays or map tiles are loading
  • the snapshot button is disabled while the viewer is loading
  • added a Snapshot section to Settings
    • show snapshot button shows or hides the button
    • include scale bar controls whether the scale bar is included in the PNG
    • export metadata JSON controls whether a JSON file is downloaded with the PNG
  • snapshot settings are saved and restored with the other viewer settings
  • the metadata JSON stores the current slide, view position, zoom, rotation, overlays and scale bar settings. It also stores overlay visibility, opacity and order
  • updated the settings tests for the new snapshot options

Example snapshot with multiple annotation overlays and the scale bar enabled:
wsi4_12k_12k_snapshot

Screenshot of the new snapshot settings tab and camera button and loading indicator:
Screenshot 2026-11-03 195915

Example metadata JSON:

{
    "url": "http://127.0.0.1:5000/?slide=slides/wsi4_12k_12k.svs&x=5518.31&y=-3264.47&zoom=3.8737166062200354",
    "slide": {
        "path": "slides/wsi4_12k_12k.svs"
    },
    "viewport": {
        "centre": [
            5518.3133369251755,
            -3264.4705189890665
        ],
        "zoom": 3.8737166062200354,
        "rotation": 0
    },
    "overlays": [
        {
            "name": "wsi4_12k_12k_semantic_segmentation",
            "path": "overlays/wsi4_12k_12k_semantic_segmentation.db",
            "visible": true,
            "opacity": 0.75,
            "zIndex": 1,
            "order": 2
        },
        {
            "name": "wsi4_12k_12k_nucleus_detections",
            "path": "overlays/wsi4_12k_12k_nucleus_detections.db",
            "visible": true,
            "opacity": 0.75,
            "zIndex": 2,
            "order": 3
        }
    ],
    "scaleBar": {
        "enabled": true,
        "included": true,
        "colour": "#ffffff",
        "opacity": 80,
        "size": "default",
        "units": "metric"
    }
}

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (c4a5afa) to head (ef6553d).

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #1184    +/-   ##
=========================================
  Coverage    99.91%   99.92%            
=========================================
  Files          117      119     +2     
  Lines        13587    13771   +184     
  Branches      1624     1624            
=========================================
+ Hits         13576    13760   +184     
  Misses           5        5            
  Partials         6        6            

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shaneahmed shaneahmed self-assigned this Nov 6, 2026
@shaneahmed shaneahmed added the enhancement New feature or request label Nov 6, 2026
@shaneahmed shaneahmed assigned Demir-B and unassigned shaneahmed Nov 6, 2026
@shaneahmed
shaneahmed self-requested a review November 6, 2026 10:23
@shaneahmed shaneahmed added this to the Release v2.2.0 milestone Nov 6, 2026
@shaneahmed

Copy link
Copy Markdown
Member

@Demir-B Please can you confirm if the exported metadata can be imported to recreate the same figure?

@shaneahmed shaneahmed changed the title Add snapshot capture to the OpenLayers viewer ✨ Add Snapshot Capture to the OpenLayers Viewer Nov 6, 2026
@Demir-B

Demir-B commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Update:

  • added Load JSON to the Snapshot settings
  • exported snapshot metadata can now be imported to recreate the saved viewer state
  • restores the slide, viewport, overlays and scale bar settings
  • restores annotation display state, including class visibility, colours, opacity, colour map and Property / Class + Property settings
  • added validation for imported snapshot metadata
  • updated the snapshot tests for metadata import

@Demir-B
Demir-B marked this pull request as ready for review November 16, 2026 19:16
@Demir-B
Demir-B marked this pull request as draft November 16, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants