Class OpenSlideLoader

java.lang.Object
qupath.lib.images.servers.openslide.jna.OpenSlideLoader

public class OpenSlideLoader extends Object
Static helper class to manage loading the OpenSlide library.
  • Constructor Details

    • OpenSlideLoader

      public OpenSlideLoader()
  • Method Details

    • tryToLoadQuietly

      public static boolean tryToLoadQuietly(String... searchPath)
      Try to load OpenSlide, but don't throw an exception if it fails.
      Parameters:
      searchPath - optional search paths that may be provided to assist with finding the preferred library.
      Returns:
      true if OpenSlide was loaded successfully, false otherwise.
    • tryToLoad

      public static boolean tryToLoad(String... searchPath) throws UnsatisfiedLinkError
      Try to load OpenSlide. This is liable to throw an exception if the library cannot be loaded.
      Parameters:
      searchPath - optional search paths that may be provided to assist with finding the preferred library.
      Returns:
      true if OpenSlide was loaded successfully, false otherwise.
      Throws:
      UnsatisfiedLinkError
    • getLibraryVersion

      public static String getLibraryVersion()
      Get the version of the OpenSlide library. This will attempt to load OpenSlide if it is not already available.
      Returns:
      a version string for the library, or null if the library is not available
    • isOpenSlideAvailable

      public static boolean isOpenSlideAvailable()
      Query whether OpenSlide has already been loaded. This will not attempt to load the library; for that, use #tryToLoadQuietly(), getLibraryVersion() or tryToLoad(String...).
      Returns:
      true if OpenSlide has been loaded successfully, false otherwise
    • openImage

      public static OpenSlide openImage(String path) throws IOException
      Open an image using OpenSlide, returning an OpenSlide instance to access pixels and metadata.

      This will attempt to load OpenSlide if it has not already been loaded, throwing an IOException if this fails. Use isOpenSlideAvailable() to check whether OpenSlide is available before calling this.

      Parameters:
      path - the image path (usually an absolute file path)
      Returns:
      an OpenSlide instance
      Throws:
      IOException - if OpenSlide could not be loaded failed to open the file
    • detectVendor

      public static String detectVendor(String path)
      Try to detect the vendor of the image at the specified path. This will attempt to load OpenSlide if it has not already been loaded.
      Parameters:
      path - the image path (usually an absolute file path)
      Returns:
      a vendor string if available, or null if OpenSlide could not be loaded or does not recognize the file