OpenSeadragon Magnification Strategy for Lens

I’m working on some tooling for an OpenSeadragon-powered app that allows a user to apply different levels of magnification inside a “lens” area. My strategy has been to create two Viewers: one visible at current zoom, another hidden at the magnified zoom level:

Example lens magnification

The good news is that things work, but at some cost to performance (esp when I try to do any pixel manipulation to image data). For anyone familiar with OpenSeadragon, is it a bad strategy to build two viewers? I can provide some code for context, but I think this might be a conceptual question.

Also for those of you familiar with the source code, it looks to me like requestAnimationFrame is applied to OpenSeadragon animations from functions like zoomTo() or panTo() – is that a fair reading?

Any insights welcome! Thanks! Be blessed!

34 thoughts on “OpenSeadragon Magnification Strategy for Lens”

  1. @jared jessup – we have recently started using openseadragon and wanted to implement the lens like magnifier just like you have done…
    It would be great help if you can share your code snippet to help us out…

    Reply
  2. That seems like a reasonable strategy. Another thing to try would be to have a single viewer with multiple copies of the image directly in the viewer (see http://openseadragon.github.io/examples/multi-image/). You could set the “magnified” image as being bigger, and move it around within the viewer in response to the user’s mouse movement. You can even give it a round clipping region via setCroppingPolygons. I don’t know if that would be better or worse performance than what you’re currently doing… Just brainstorming.

    As for requestAnimationFrame, OpenSeadragon has one such loop for all animation. It also uses requestAnimationFrame for some utility functions, like fading buttons and continuing to zoom while the user holds down the mouse button on the zoom button.

    Reply

Leave a Comment