From 079c5a0eece37c2eb4335b1f149802fb5e7053aa Mon Sep 17 00:00:00 2001 From: Marc Aubreville Date: Wed, 22 Apr 2026 14:19:42 +0200 Subject: [PATCH 1/2] Added screenshoting --- .../annotations/js/exact-image-viewer.js | 39 +++++++++++++++++++ .../templates/annotations/annotate.html | 4 +- .../templates/annotations/annotate_v2.html | 4 +- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/exact/exact/annotations/static/annotations/js/exact-image-viewer.js b/exact/exact/annotations/static/annotations/js/exact-image-viewer.js index 589d72b0..74b1a486 100644 --- a/exact/exact/annotations/static/annotations/js/exact-image-viewer.js +++ b/exact/exact/annotations/static/annotations/js/exact-image-viewer.js @@ -609,6 +609,18 @@ class EXACTViewer { }); viewer.buttons.buttons.push(showNavigationButton); viewer.buttons.element.appendChild(showNavigationButton.element); + + let screenshotButton = new OpenSeadragon.Button({ + tooltip: 'Download screenshot of current view', + name: "Screenshot", + srcRest: viewer.prefixUrl + `screenshot.svg`, + srcGroup: viewer.prefixUrl + `screenshot.svg`, + srcHover: viewer.prefixUrl + `screenshot_hover.svg`, + srcDown: viewer.prefixUrl + `screenshot.svg`, + onClick: this.takeScreenshot.bind(this), + }); + viewer.buttons.buttons.push(screenshotButton); + viewer.buttons.element.appendChild(screenshotButton.element); } handleKeyUp(event) { @@ -665,6 +677,33 @@ class EXACTViewer { } } + takeScreenshot() { + const osdCanvas = this.viewer.drawer.canvas; + const overlayCanvas = document.getElementById('osd-overlaycanvas'); + + const width = osdCanvas.width; + const height = osdCanvas.height; + + const composite = document.createElement('canvas'); + composite.width = width; + composite.height = height; + const ctx = composite.getContext('2d'); + + ctx.drawImage(osdCanvas, 0, 0); + if (overlayCanvas) { + ctx.drawImage(overlayCanvas, 0, 0); + } + + const imageName = (this.imageInformation && this.imageInformation.name) + ? this.imageInformation.name.replace(/\.[^.]+$/, '') + : 'screenshot'; + + const link = document.createElement('a'); + link.download = imageName + '_screenshot.png'; + link.href = composite.toDataURL('image/png'); + link.click(); + } + finishAnnotation() { return; } diff --git a/exact/exact/annotations/templates/annotations/annotate.html b/exact/exact/annotations/templates/annotations/annotate.html index 740b8a5b..75625b25 100644 --- a/exact/exact/annotations/templates/annotations/annotate.html +++ b/exact/exact/annotations/templates/annotations/annotate.html @@ -860,8 +860,8 @@
{{ selected_image.name }}
-
-
+
+
diff --git a/exact/exact/annotations/templates/annotations/annotate_v2.html b/exact/exact/annotations/templates/annotations/annotate_v2.html index 9887d920..0b595869 100644 --- a/exact/exact/annotations/templates/annotations/annotate_v2.html +++ b/exact/exact/annotations/templates/annotations/annotate_v2.html @@ -875,8 +875,8 @@
{{ selected_image.name }}
-
-
+
+
From 27c61a8fac140098c8b5dd924cbebbce89d09a42 Mon Sep 17 00:00:00 2001 From: Marc Aubreville Date: Wed, 22 Apr 2026 14:21:26 +0200 Subject: [PATCH 2/2] Added files --- .../annotations/static/images/screenshot.svg | 57 +++++++++++++++++++ .../static/images/screenshot_hover.svg | 57 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 exact/exact/annotations/static/images/screenshot.svg create mode 100644 exact/exact/annotations/static/images/screenshot_hover.svg diff --git a/exact/exact/annotations/static/images/screenshot.svg b/exact/exact/annotations/static/images/screenshot.svg new file mode 100644 index 00000000..b65e1b22 --- /dev/null +++ b/exact/exact/annotations/static/images/screenshot.svg @@ -0,0 +1,57 @@ + + + + + + + + + diff --git a/exact/exact/annotations/static/images/screenshot_hover.svg b/exact/exact/annotations/static/images/screenshot_hover.svg new file mode 100644 index 00000000..c783a044 --- /dev/null +++ b/exact/exact/annotations/static/images/screenshot_hover.svg @@ -0,0 +1,57 @@ + + + + + + + + +