npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openseadragon-imaging/openseadragon-imaginghelper

v2.2.2

Published

OpenSeadragon plugin which adds helper properties/methods for imaging applications.

Downloads

144

Readme

OpenSeadragonImagingHelper

Gitter

OpenSeadragonImagingHelper is a plugin for OpenSeadragon which implements some properties and methods helpful in imaging applications.

View the Documentation

Demo/Test Site

Usage

Prerequisite note: OpenSeadragonImagingHelper requires OpenSeadragon version 2.0+.

The OpenSeadragonImagingHelper bundle can be obtained the following ways:

  1. Direct download openseadragon-imaginghelper.js (and optionally openseadragon-imaginghelper.js.map)
  2. npm
    npm install @openseadragon-imaging/openseadragon-imaginghelper

The OpenSeadragonImagingHelper bundle can be included using a script tag in HTML or imported as a library module (ES2015, CommonJS, AMD).

An ImagingHelper object can be created and attached to an OpenSeadragon.Viewer two ways:

  1. Call the activateImagingHelper method on the viewer
  2. Create a new ImagingHelper object, passing a viewer reference in the options parameter

Both methods return a new ImagingHelper object, and both methods also add the ImagingHelper object reference to the viewer as a property called 'imagingHelper'.

Example using an HTML script tag

<script
  type="text/javascript"
  src="path_to/openseadragon/openseadragon.js"
></script>
<script
  type="text/javascript"
  src="path_to/openseadragon-imaging/openseadragon-imaginghelper.js"
></script>
    // Example 1 - Use the Viewer.activateImagingHelper() method to create an ImagingHelper

    // create an OpenSeadragon viewer
    var viewer = window.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 window.OpenSeadragonImaging.ImagingHelper({viewer: existingviewer});

Example importing as a module

    npm install openseadragon --save
    npm install @openseadragon-imaging/openseadragon-imaginghelper --save
import OpenSeadragon from 'openseadragon';
import OpenSeadragonImagingHelper from '@openseadragon-imaging/openseadragon-imaginghelper';

    // 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 OpenSeadragonImagingHelper({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 dimensions

Methods 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 objects)

The ImagingHelper class extends the OpenSeadragon.EventSource class and raises an event named 'image-view-changed' whenever the viewer's zoom and/or pan position changes.

    // Event Example 1 - Use the options 'onImageViewChanged' property to set a handler

    var 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 site is an example using ImagingHelper in a React application. 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.

The source code can be found here.

Legacy Demo/Test Site

The old demo site is still available here. This page adds an example of syncing an SVG overlay for annotation support.

All the sample code is in scripts/viewmodel.js.

TODO

  1. Better multi-image support