imageToViewportRectangle not working as expected
See original GitHub issueI am using OpenSeadragon to view an image and crop regions from it. The cropped regions are stored in a database using their image coordinates (in pixels). I want the cropped images to appear when I reopen the page.
I can add the overlay if I do the following
var overlayElement = document.createElement('div');
overlayElement.id = 'region_box_' + String(region_num);
overlayElement.style.border = "4px solid green";
var rect = new OpenSeadragon.Rect({{region.x}}/viewer.source.width;, {{region.y}}/ viewer.source.height, {{region.width}}/viewer.source.width;, {{region.height}}/viewer.source.height)
viewer.addOverlay(overlayElement, rect);
Is there a better way to do this? I had expected this to work, but it does not transform the coordinates at all so I must be using it incorrectly:
rect = viewer.viewport.imageToViewportRectangle({{region.x}}, {{region.y}}, {{region.width}}, {{region.height}})
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Overlay to Image Rectangle · Issue #787 - GitHub
I'd like to be able to pass the pixels back to allow for cropping, etc. ... var overlay = viewer.viewport.imageToViewportRectangle(x, y, w, h);...
Read more >openseadragon/openseadragon - Gitter
I understand the various 'points' displayed on the coordinates page, but I'm struggling to make sense of the rectangles I need to work...
Read more >Adding/positioning independent overlays to openseadragon ...
Looks like this is a bug with OpenSeadragon! Here's the issue ticket: https://github.com/openseadragon/openseadragon/issues/1412.
Read more >Source: openseadragon.js
NOTE: usually, post data is expected to be ampersand-separated (just ... Preexisting formats that are not being updated are left unchanged.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Happy to know that you resolve the issue!
That fixed it - thanks!