Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msalsbery/OpenSeadragonImagingHelper
https://github.com/msalsbery/OpenSeadragonImagingHelper
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/msalsbery/OpenSeadragonImagingHelper
- Owner: msalsbery
- License: mit
- Created: 2013-10-04T23:56:30.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T16:26:56.000Z (6 months ago)
- Last Synced: 2024-11-08T02:44:38.933Z (about 2 months ago)
- Language: JavaScript
- Size: 2.72 MB
- Stars: 19
- Watchers: 6
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-iiif - Imaging Helper Plugin - OpenSeadragon plugin with utility functions. (Image API Libraries / Image viewers (Image API only))
README
## OpenSeadragonImagingHelper
[![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/msalsbery/OpenSeadragonImaging?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)OpenSeadragonImagingHelper is a plugin for [OpenSeadragon](https://github.com/openseadragon/openseadragon)
which implements some properties and methods helpful in
imaging applications.[View the Documentation](http://msalsbery.github.io/openseadragon-imaging/docs/openseadragon-imaginghelper/index.html)
[See the OpenSeadragon Imaging Demo/Test Site Live](http://msalsbery.github.io/openseadragon-imaging/demo/index.html)
### Usage
Download [openseadragon-imaginghelper.min.js](http://msalsbery.github.io/openseadragon-imaging/builds/openseadragon-imaginghelper.min.js) (or the un-minified [openseadragon-imaginghelper.js](http://msalsbery.github.io/openseadragon-imaging/builds/openseadragon-imaginghelper.js))
To use the plugin, add **openseadragon-imaginghelper.min.js** after **openseadragon.min.js** to your site.
An **ImagingHelper** object can be created and attached to an [OpenSeadragon.Viewer](http://openseadragon.github.io/docs/OpenSeadragon.Viewer.html) two ways:
1. Call the activateImagingHelper method on the viewer
2. Create a new ImagingHelper object, passing a viewer reference in the options parameterBoth methods return a new ImagingHelper object, and both methods also add the ImagingHelper
object reference to the viewer as a property called 'imagingHelper'.```javascript
// Example 1 - Use the Viewer.activateImagingHelper() method to create an ImagingHelper// create an OpenSeadragon viewer
var viewer = OpenSeadragon({...});
// add an ImagingHelper to the viewer
var imagingHelper = viewer.activateImagingHelper({...});// Example 2 - Attach a new ImagingHelper to an existing OpenSeadragon.Viewer
var imagingHelper = new OpenSeadragonImaging.ImagingHelper({viewer: existingviewer});
```### Details
The ImagingHelper class provides a simplified zoomFactor which is simply the ratio
of the displayed image pixel size to the image's native pixel size.In OpenSeadragon 2.0 and above, conversion is based on the image at index 0 in world.getItemAt, unless another value is set by the worldIndex option.
The ImagingHelper methods use three coordinate systems,
named as follows:1. **physical:** Device pixel coordinates relative to the SeaDragon viewer
2. **logical:** 0.0 to 1.0 relative to the image's native dimensions
3. **data:** Pixel coordinates relative to the image's native dimensionsMethods are provided to zoom and/or pan using these conventions, as well as to convert
individual horizontal/vertical values or point ({x,y}) objects between coordinate systems
**(Note: methods that return a point object return new [OpenSeadragon.Point](http://openseadragon.github.io/docs/OpenSeadragon.Point.html)
objects)**The ImagingHelper class extends the [OpenSeadragon.EventSource](http://openseadragon.github.io/docs/OpenSeadragon.EventHandler.html) class and raises
an event named **'image-view-changed'** whenever the viewer's zoom and/or pan position changes.```javascript
// Event Example 1 - Use the options 'onImageViewChanged' property to set a handlervar viewer = OpenSeadragon({...});
var imagingHelper = viewer.activateImagingHelper({onImageViewChanged: onImageViewChanged});function onImageViewChanged(event) {
// event.viewportWidth == width of viewer viewport in logical coordinates relative to image native size
// event.viewportHeight == height of viewer viewport in logical coordinates relative to image native size
// event.viewportOrigin == OpenSeadragon.Point, top-left of the viewer viewport in logical coordinates relative to image
// event.viewportCenter == OpenSeadragon.Point, center of the viewer viewport in logical coordinates relative to image
// event.zoomFactor == current zoom factor
...
}// Event Example 2 - Add a handler to an existing ImagingHelper
imagingHelper.addHandler('image-view-changed', function (event) {
// event.viewportWidth == width of viewer viewport in logical coordinates relative to image native size
// event.viewportHeight == height of viewer viewport in logical coordinates relative to image native size
// event.viewportOrigin == OpenSeadragon.Point, top-left of the viewer viewport in logical coordinates relative to image
// event.viewportCenter == OpenSeadragon.Point, center of the viewer viewport in logical coordinates relative to image
// event.zoomFactor == current zoom factor
...
});
```### Demo/Test Site
The 'demo' folder provides a demo/test site.
The page displays many OpenSeadragon and OpenSeadragonImagingHelper metrics, as well as the output of many OpenSeadragonImagingHelper methods,
all in real-time as the cursor moves and/or the image is zoomed/panned. Four sample images are provided.Additionally, there's an example of syncing an SVG overlay for annotation support.
All the sample code is in [demo/scripts/viewmodel.js](http://msalsbery.github.io/openseadragon-imaging/demo/scripts/viewmodel.js).
### Notes
### In the works...
1) Better multi-image support