Class ThumbnailHandler

java.lang.Object
io.goobi.viewer.controller.imaging.ThumbnailHandler

public class ThumbnailHandler extends Object
Delivers Thumbnail urls for pages and StructElements.
Author:
Florian Alpers
  • Field Details

    • REQUIRED_SOLR_FIELDS

      public static final Set<String> REQUIRED_SOLR_FIELDS
      Constant REQUIRED_SOLR_FIELDS.
  • Constructor Details

    • ThumbnailHandler

      public ThumbnailHandler(IIIFUrlHandler iiifUrlHandler, String staticImagesPath)

      Constructor for ThumbnailHandler.

      Parameters:
      iiifUrlHandler - a IIIFUrlHandler object.
      staticImagesPath - a String object.
    • ThumbnailHandler

      public ThumbnailHandler(URI apiUrl, String staticImagesPath)
  • Method Details

    • getThumbnailPath

      public URI getThumbnailPath(String filename)

      getThumbnailPath.

      Parameters:
      filename - a String object.
      Returns:
      a URI object.
    • getThumbnailUrl

      public String getThumbnailUrl(PhysicalElement page)
      Returns a link to a small image representing the given page. The size depends on viewer configuration.
      Parameters:
      page - a PhysicalElement object.
      Returns:
      a String object.
    • getThumbnailUrl

      Returns a link to the representative image for the given pi. If the pi doesn't match an indexed item, null is returned.
      Parameters:
      pi - the persistent identifier of the work which representative we want
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • getThumbnailUrl

      public String getThumbnailUrl(String pi, int width, int height) throws IndexUnreachableException, PresentationException, ViewerConfigurationException
      Returns a link to the representative image for the given pi with the given width and height. If the pi doesn't match an indexed item, null is returned
      Parameters:
      pi - the persistent identifier of the work which representative we want
      width - the width of the image
      height - the height of the image
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • getImageUrl

      public String getImageUrl(String pi, int width, int height, String format) throws IndexUnreachableException, PresentationException, ViewerConfigurationException
      Returns a link to the representative image for the given pi with the given width and height. If the pi doesn't match an indexed item, null is returned
      Parameters:
      pi - the persistent identifier of the work which representative we want
      width - the width of the image
      height - the height of the image
      format - the file extension of the desired format. Possible values are 'jpg', 'tif' and 'png'
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      Returns a link to a square representative image for the given pi. If the pi doesn't match an indexed item, null is returned.
      Parameters:
      pi - the persistent identifier of the work which representative we want
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(String pi, int size) throws IndexUnreachableException, PresentationException, ViewerConfigurationException
      Returns a link to a square representative image for the given pi. If the pi doesn't match an indexed item, null is returned.
      Parameters:
      pi - the persistent identifier of the work which representative we want
      size - the size (width and heigt) of the image
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      ViewerConfigurationException - if any.
    • getThumbnailUrl

      Returns a link to the image of the page of the given order (=page number) within the work with the given pi . If the pi doesn't match an indexed work or the work desn't contain a page of the given order, null is returned.
      Parameters:
      order - the page number
      pi - the persistent identifier of the work which representative we want
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getThumbnailUrl

      public String getThumbnailUrl(int order, String pi, int width, int height) throws ViewerConfigurationException
      Returns a link to the image of the page of the given order (=page number) within the work with the given pi of the given width and height. If the pi doesn't match an indexed work or the work desn't contain a page of the given order, null is returned.
      Parameters:
      order - the page number
      pi - the persistent identifier of the work which representative we want
      width - the width of the image
      height - the height of the image
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      Returns a link to a square image of the page of the given order (=page number) within the work with the given pi. If the pi doesn't match an indexed work or the work desn't contain a page of the given order, null is returned.
      Parameters:
      order - the page number
      pi - the persistent identifier of the work which representative we want
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(int order, String pi, int size) throws IndexUnreachableException, PresentationException, DAOException, ViewerConfigurationException
      Returns a link to a square image of the page of the given order (=page number) within the work with the given pi of the given size. If the pi doesn't match an indexed work or the work desn't contain a page of the given order, null is returned.
      Parameters:
      order - the page number
      pi - the persistent identifier of the work which representative we want
      size - the width and height of the image
      Returns:
      The url string or null of no work is found
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getPage

      getPage.

      Parameters:
      pi - a String object.
      order - a int.
      Returns:
      a PhysicalElement object.
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
      DAOException - if any.
    • getThumbnailUrl

      public String getThumbnailUrl(PhysicalElement page, int width, int height)
      Returns a link to an image representing the given page of the given size (to be exact: the largest image size which fits within the given bounds and keeps the image proportions.
      Parameters:
      page - a PhysicalElement object.
      width - a int.
      height - a int.
      Returns:
      a String object.
    • getImageUrl

      public String getImageUrl(PhysicalElement page, int width, int height, String format)
      Returns a link to an image representing the given page of the given size (to be exact: the largest image size which fits within the given bounds and keeps the image proportions.
      Parameters:
      page - a PhysicalElement object.
      width - a int.
      height - a int.
      format - the file extension of the desiref format. Possible values are 'jpg', 'tif' and 'png'
      Returns:
      a String object.
    • getImageFileFormat

      public static de.unigoettingen.sub.commons.contentlib.imagelib.ImageFileFormat getImageFileFormat(PhysicalElement page, String format)
    • getThumbnailUrl

      public String getThumbnailUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale)

      getThumbnailUrl.

      Parameters:
      page - a PhysicalElement object.
      scale - a Scale object.
      Returns:
      a String object.
    • getImageUrl

      public String getImageUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, de.unigoettingen.sub.commons.contentlib.imagelib.ImageFileFormat format)

      getThumbnailUrl.

      Parameters:
      page - a PhysicalElement object.
      scale - a Scale object.
      format - the file extension of the desired format. Possible values are 'jpg', 'tif' and 'png'
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(PhysicalElement page)
      Returns a link the an image representing the given page. Its size depends on configuration. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      page - a PhysicalElement object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(PhysicalElement page, int size)
      Returns a link the an image representing the given page of the given size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      page - a PhysicalElement object.
      size - a int.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(StructElement doc)
      Returns a link to a small image representing the given document. The size depends on viewer configuration.
      Parameters:
      doc - a StructElement object.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(StructElement doc, String pi)
      Returns a link to a small image representing the given document with the given pi. The size depends on viewer configuration.
      Parameters:
      doc - a StructElement object.
      pi - a String object.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(org.apache.solr.common.SolrDocument doc) throws ViewerConfigurationException
      Returns a link to a small image representing the given document. The size depends on viewer configuration.
      Parameters:
      doc - a SolrDocument object.
      Returns:
      a String object.
      Throws:
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(org.apache.solr.common.SolrDocument doc) throws ViewerConfigurationException
      Returns a link to a small image representing the given document. The size depends on viewer configuration. The image may be cut at the longer side to provide a square image.
      Parameters:
      doc - a SolrDocument object.
      Returns:
      a String object.
      Throws:
      ViewerConfigurationException - if any.
    • getThumbnailUrl

      public String getThumbnailUrl(org.apache.solr.common.SolrDocument doc, int width, int height) throws ViewerConfigurationException
      Returns a link to an image representing the given page of the given size (to be exact: the largest image size which fits within the given bounds and keeps the image proportions.
      Parameters:
      doc - a SolrDocument object.
      width - a int.
      height - a int.
      Returns:
      a String object.
      Throws:
      ViewerConfigurationException - if any.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(org.apache.solr.common.SolrDocument doc, int size) throws ViewerConfigurationException
      Returns a link to an image representing the given page of the given size. The image will be cut at the longer side to create a square image.
      Parameters:
      doc - a SolrDocument object.
      size - a int.
      Returns:
      a String object.
      Throws:
      ViewerConfigurationException - if any.
    • getThumbnailUrl

      public String getThumbnailUrl(StructElement se, int width, int height)
      Returns a link to an image representing the given document of the given size (to be exact: the largest image size which fits within the given bounds and keeps the image proportions.
      Parameters:
      se - Needs to have the fields SolrConstants.MIMETYPE and SolrConstants.THUMBNAIL
      width - a int.
      height - a int.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(StructElement doc, String pi, int width, int height)

      getThumbnailUrl.

      Parameters:
      doc - a StructElement object.
      pi - a String object.
      width - a int.
      height - a int.
      Returns:
      a String object.
    • getFullImageUrl

      public String getFullImageUrl(PhysicalElement page)

      getFullImageUrl.

      Parameters:
      page - a {)@link io.goobi.viewer.model.viewer.PhysicalElement} object.
      Returns:
      the url of the entire, max-size image in the original format. If no Watermark needs to be included and forwarding images is allowed in contentServer, then this streams the original image file to the client
    • getFullImageUrl

      public String getFullImageUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, String formatString)

      getFullImageUrl.

      Parameters:
      page - a PhysicalElement object.
      scale - a Scale object.
      formatString - file extension for the desired format. May also be 'master' to indicate that the format of the original file should be used
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(StructElement se)
      Returns a link the an image representing the given document. Its size depends on configuration. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      se - a StructElement object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(StructElement se, int size)
      Returns a link the an image representing the given document of the given size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      se - Needs to have the fields SolrConstants.MIMETYPE and SolrConstants.THUMBNAIL
      size - a int.
      Returns:
      a String object.
    • getDocumentImagePath

      public String getDocumentImagePath(StructElement doc, String thumbnailUrl)
      Parameters:
      doc -
      thumbnailUrl -
      Returns:
      String
    • getDocStructImagePath

      public String getDocStructImagePath(StructElement doc, String thumbnailUrl)
      Parameters:
      doc -
      thumbnailUrl -
      Returns:
      String
    • getAnchorImagePath

      public String getAnchorImagePath(StructElement doc, String thumbnailUrl, String anchorThumbnailMode)
      Parameters:
      doc -
      thumbnailUrl -
      anchorThumbnailMode -
      Returns:
      String
    • getCMSPageImagePath

      public String getCMSPageImagePath(StructElement doc, String thumbnailUrl)
      Parameters:
      doc -
      thumbnailUrl -
      Returns:
      String
    • getThumbnailUrl

      public String getThumbnailUrl(Optional<CMSMediaItem> item)
      Return the url to the image of the given CMSMediaItem, fit into a box of the default width and height.
      Parameters:
      item - a Optional object.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(CMSMediaItem item)
      Return the url to the image of the given CMSMediaItem, fit into a box of the default width and height.
      Parameters:
      item - a CMSMediaItem object.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(Optional<CMSMediaItem> optional, int width, int height)
      Return the url to the image of the given CMSMediaItem, fit into a box of the given width and height.
      Parameters:
      width - a int.
      height - a int.
      optional - a Optional object.
      Returns:
      a String object.
    • getThumbnailUrl

      public String getThumbnailUrl(URI baseUri)
      Get the thumbnailUrl for a IIIF image identifier with default size.
      Parameters:
      baseUri - IIIF image identifier
      Returns:
      Generated URL
    • getThumbnailUrl

      public String getThumbnailUrl(URI baseUri, int width, int height)
      Get the thumbnailUrl for a IIIF image identifier.
      Parameters:
      baseUri - IIIF image identifier
      width - thumbnail width
      height - thumbnail height
      Returns:
      Generated URL
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(URI baseUri)
      Get the square thumbnailUrl for a IIIF image identifier with default size.
      Parameters:
      baseUri - IIIF image identifier
      Returns:
      Generated URL
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(URI baseUri, int size)
      Get the square thumbnailUrl for a IIIF image identifier.
      Parameters:
      baseUri - IIIF image identifier
      size - thumbnail size
      Returns:
      Generated URL
    • getThumbnailUrl

      public String getThumbnailUrl(URI baseUri, int width, int height, boolean square)
      Get the thumbnailUrl for a IIIF image identifier.
      Parameters:
      baseUri - IIIF image identifier
      width - thumbnail width
      height - thumbnail height
      square - true to deliver a square image
      Returns:
      Generated URL
    • getCMSMediaImageApiUrl

      public static String getCMSMediaImageApiUrl(String filename)
      Parameters:
      filename -
      Returns:
      Generated URL
    • getCMSMediaImageApiUrl

      public static String getCMSMediaImageApiUrl(String filename, String restApiUrl)
    • getThumbnailUrl

      public String getThumbnailUrl(CMSMediaItem media, int width, int height)
      Return the url to the image of the given CMSMediaItem, fit into a box of the given width and height.
      Parameters:
      width - a int.
      height - a int.
      media - a CMSMediaItem object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(Optional<CMSMediaItem> optional, int size)
      Return the url to the image of the given CMSMediaItem of the given size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      size - a int.
      optional - a Optional object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(CMSMediaItem media, int size)
      Return the url to the image of the given CMSMediaItem of the given size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      size - a int.
      media - a CMSMediaItem object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(Optional<CMSMediaItem> item)
      Return the url to the image of the given CMSMediaItem of the default size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.n
      Parameters:
      item - a Optional object.
      Returns:
      a String object.
    • getSquareThumbnailUrl

      public String getSquareThumbnailUrl(CMSMediaItem item)
      Return the url to the image of the given CMSMediaItem of the default size. The image is always square and contains as much of the actual image as is possible to fit into a square - the delivered square is always centered within the full image.
      Parameters:
      item - a CMSMediaItem object.
      Returns:
      a String object.
    • isStaticImageResource

      public boolean isStaticImageResource(String thumbnailUrl)
      Tests whether the given url refers to an image within the viewer image resource folder.
      Parameters:
      thumbnailUrl - a String object.
      Returns:
      true if the url starts with the viewer url path to image resources