Class ThumbnailHandler
java.lang.Object
io.goobi.viewer.controller.imaging.ThumbnailHandler
Delivers Thumbnail urls for pages and StructElements.
- Author:
- Florian Alpers
-
Field Summary
FieldsModifier and TypeFieldDescriptionConstantREQUIRED_SOLR_FIELDS. -
Constructor Summary
ConstructorsConstructorDescriptionThumbnailHandler(IIIFUrlHandler iiifUrlHandler, String staticImagesPath) Creates a new ThumbnailHandler instance.ThumbnailHandler(URI apiUrl, String staticImagesPath) -
Method Summary
Modifier and TypeMethodDescriptiongetAnchorImagePath(StructElement doc, String thumbnailUrl, String anchorThumbnailMode) static StringgetCMSMediaImageApiUrl(String filename) static StringgetCMSMediaImageApiUrl(String filename, String restApiUrl) getCMSPageImagePath(StructElement doc, String thumbnailUrl) getDocStructImagePath(StructElement doc, String thumbnailUrl) getDocumentImagePath(StructElement doc, String thumbnailUrl) getFullImageUrl.getFullImageUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, String formatString) getFullImageUrl.static de.unigoettingen.sub.commons.contentlib.imagelib.ImageFileFormatgetImageFileFormat(PhysicalElement page, String format) 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.getImageUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale, de.unigoettingen.sub.commons.contentlib.imagelib.ImageFileFormat format) getThumbnailUrl.getImageUrl(String pi, int width, int height, String format) Returns a link to the representative image for the given pi with the given width and height.static PhysicalElementgetPage.getSquareThumbnailUrl(int order, String pi) Returns a link to a square image of the page of the given order (=page number) within the work with the given pi.getSquareThumbnailUrl(int order, String pi, int size) 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.Return the url to the image of the givenCMSMediaItemof the default size.getSquareThumbnailUrl(CMSMediaItem media, int size) Return the url to the image of the givenCMSMediaItemof the given size.Returns a link the an image representing the given page.getSquareThumbnailUrl(PhysicalElement page, int size) Returns a link the an image representing the given page of the given size.Returns a link the an image representing the given document.getSquareThumbnailUrl(StructElement se, int size) Returns a link the an image representing the given document of the given size.Returns a link to a square representative image for the given pi.getSquareThumbnailUrl(String pi, int size) Returns a link to a square representative image for the given pi.getSquareThumbnailUrl(URI baseUri) Get the square thumbnailUrl for a IIIF image identifier with default size.getSquareThumbnailUrl(URI baseUri, int size) Get the square thumbnailUrl for a IIIF image identifier.Return the url to the image of the givenCMSMediaItemof the default size.getSquareThumbnailUrl(Optional<CMSMediaItem> optional, int size) Return the url to the image of the givenCMSMediaItemof the given size.getSquareThumbnailUrl(org.apache.solr.common.SolrDocument doc) Returns a link to a small image representing the given document.getSquareThumbnailUrl(org.apache.solr.common.SolrDocument doc, int size) Returns a link to an image representing the given page of the given size.getThumbnailPath(String filename) getThumbnailPath.getThumbnailUrl(int order, String pi) Returns a link to the image of the page of the given order (=page number) within the work with the given pi .getThumbnailUrl(int order, String pi, int width, int height) 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.getThumbnailUrl(CMSMediaItem item) Return the url to the image of the givenCMSMediaItem, fit into a box of the default width and height.getThumbnailUrl(CMSMediaItem media, int width, int height) Return the url to the image of the givenCMSMediaItem, fit into a box of the given width and height.Returns a link to a small image representing the given page.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.getThumbnailUrl(PhysicalElement page, de.unigoettingen.sub.commons.contentlib.imagelib.transform.Scale scale) getThumbnailUrl.Returns a link to a small image representing the given document.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.getThumbnailUrl(StructElement doc, String pi) Returns a link to a small image representing the given document with the given pi.getThumbnailUrl(StructElement doc, String pi, int width, int height) getThumbnailUrl.Returns a link to the representative image for the given pi.getThumbnailUrl(String pi, int width, int height) Returns a link to the representative image for the given pi with the given width and height.getThumbnailUrl(URI baseUri) Get the thumbnailUrl for a IIIF image identifier with default size.getThumbnailUrl(URI baseUri, int width, int height) Get the thumbnailUrl for a IIIF image identifier.getThumbnailUrl(URI baseUri, int width, int height, boolean square) Get the thumbnailUrl for a IIIF image identifier.getThumbnailUrl(Optional<CMSMediaItem> item) Return the url to the image of the givenCMSMediaItem, fit into a box of the default width and height.getThumbnailUrl(Optional<CMSMediaItem> optional, int width, int height) Return the url to the image of the givenCMSMediaItem, fit into a box of the given width and height.getThumbnailUrl(org.apache.solr.common.SolrDocument doc) Returns a link to a small image representing the given document.getThumbnailUrl(org.apache.solr.common.SolrDocument doc, 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.booleanisStaticImageResource(String thumbnailUrl) Tests whether the given url refers to an image within the viewer image resource folder.
-
Field Details
-
REQUIRED_SOLR_FIELDS
ConstantREQUIRED_SOLR_FIELDS.
-
-
Constructor Details
-
ThumbnailHandler
Creates a new ThumbnailHandler instance.- Parameters:
iiifUrlHandler- handler used to build IIIF image URLsstaticImagesPath- base path to the viewer's static image resources
-
ThumbnailHandler
-
-
Method Details
-
getThumbnailPath
getThumbnailPath.- Parameters:
filename- file name to resolve against the static images path- Returns:
- the URI of the resolved static image path
-
getThumbnailUrl
Returns a link to a small image representing the given page. The size depends on viewer configuration.- Parameters:
page- physical page element to render as thumbnail- Returns:
- the thumbnail image URL for the given page at the configured default size
-
getThumbnailUrl
public String getThumbnailUrl(String pi) throws IndexUnreachableException, PresentationException, ViewerConfigurationException 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 wantwidth- the width of the imageheight- 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 wantwidth- the width of the imageheight- the height of the imageformat- 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
public String getSquareThumbnailUrl(String pi) 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- 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 wantsize- 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
public String getThumbnailUrl(int order, String pi) throws IndexUnreachableException, PresentationException, DAOException, ViewerConfigurationException 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 numberpi- 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 numberpi- the persistent identifier of the work which representative we wantwidth- the width of the imageheight- 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
public String getSquareThumbnailUrl(int order, String pi) 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. 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 numberpi- 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 numberpi- the persistent identifier of the work which representative we wantsize- 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
public static PhysicalElement getPage(String pi, int order) throws IndexUnreachableException, PresentationException, DAOException getPage.- Parameters:
pi- persistent identifier of the parent workorder- physical page order number within the work- Returns:
- the PhysicalElement at the given order position within the record, or null if not found
- Throws:
IndexUnreachableException- if any.PresentationException- if any.DAOException- if any.
-
getThumbnailUrl
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- physical page element to render as thumbnailwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given page scaled to fit within the given bounds
-
getImageUrl
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- physical page element to renderwidth- maximum image width in pixelsheight- maximum image height in pixelsformat- the file extension of the desiref format. Possible values are 'jpg', 'tif' and 'png'- Returns:
- the image URL for the given page scaled to fit within the given bounds in the specified format
-
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- physical page element to render as thumbnailscale- scaling parameters defining the output size- Returns:
- the thumbnail image URL for the given page at the given scale
-
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- physical page element to renderscale- scaling parameters defining the output sizeformat- the file extension of the desired format. Possible values are 'jpg', 'tif' and 'png'- Returns:
- the image URL for the given page at the given scale in the given format
-
getSquareThumbnailUrl
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- physical page element to render as square thumbnail- Returns:
- the square thumbnail image URL for the given page at the configured default size
-
getSquareThumbnailUrl
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- physical page element to render as square thumbnailsize- width and height of the square image in pixels- Returns:
- the square thumbnail image URL for the given page at the given size
-
getThumbnailUrl
Returns a link to a small image representing the given document. The size depends on viewer configuration.- Parameters:
doc- struct element representing the document to thumbnail- Returns:
- the thumbnail image URL for the given document at the configured default size
-
getThumbnailUrl
Returns a link to a small image representing the given document with the given pi. The size depends on viewer configuration.- Parameters:
doc- struct element representing the document to thumbnailpi- persistent identifier used in the generated URL- Returns:
- the thumbnail image URL for the given document at the configured default size
-
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- Solr document representing the record to thumbnail- Returns:
- the thumbnail image URL for the given Solr document at the configured default size
- 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- Solr document representing the record to thumbnail- Returns:
- the square thumbnail image URL for the given Solr document at the configured default size
- 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- Solr document representing the record to thumbnailwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given Solr document scaled to fit within the given bounds
- 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- Solr document representing the record to thumbnailsize- width and height of the square image in pixels- Returns:
- the square thumbnail image URL for the given Solr document at the given size
- Throws:
ViewerConfigurationException- if any.
-
getThumbnailUrl
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 fieldsSolrConstants.MIMETYPEandSolrConstants.THUMBNAILwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given struct element scaled to fit within the given bounds
-
getThumbnailUrl
getThumbnailUrl.- Parameters:
doc- struct element representing the document to thumbnailpi- persistent identifier used in the generated URLwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given struct element at the given PI and scaled to fit within the given bounds
-
getFullImageUrl
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- physical page element to render at full sizescale- scaling parameters applied to the full imageformatString- file extension for the desired format. May also be 'master' to indicate that the format of the original file should be used- Returns:
- the full image URL for the given page at the given scale and format
-
getSquareThumbnailUrl
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- struct element representing the document to thumbnail- Returns:
- the square thumbnail image URL for the given struct element at the configured default size
-
getSquareThumbnailUrl
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 fieldsSolrConstants.MIMETYPEandSolrConstants.THUMBNAILsize- width and height of the square image in pixels- Returns:
- the square thumbnail image URL for the given struct element at the given size
-
getDocumentImagePath
- Parameters:
doc- struct element whose image path to resolvethumbnailUrl- fallback thumbnail URL if no specific path is determined- Returns:
- String
-
getDocStructImagePath
- Parameters:
doc- struct element whose docstrct image path to resolvethumbnailUrl- fallback thumbnail URL if no specific path is determined- Returns:
String
-
getAnchorImagePath
public String getAnchorImagePath(StructElement doc, String thumbnailUrl, String anchorThumbnailMode) - Parameters:
doc- anchor or group struct element whose image path to resolvethumbnailUrl- fallback thumbnail URL if no specific path is determinedanchorThumbnailMode- configured mode for selecting the anchor thumbnail- Returns:
String
-
getCMSPageImagePath
- Parameters:
doc- CMS page struct element whose representative image path to resolvethumbnailUrl- fallback thumbnail URL if no CMS media item is found- Returns:
- String
-
getThumbnailUrl
Return the url to the image of the givenCMSMediaItem, fit into a box of the default width and height.- Parameters:
item- optional CMS media item to render as thumbnail- Returns:
- the thumbnail image URL for the given CMS media item at the configured default size
-
getThumbnailUrl
Return the url to the image of the givenCMSMediaItem, fit into a box of the default width and height.- Parameters:
item- CMS media item to render as thumbnail- Returns:
- the thumbnail image URL for the given CMS media item at the configured default size
-
getThumbnailUrl
Return the url to the image of the givenCMSMediaItem, fit into a box of the given width and height.- Parameters:
optional- optional CMS media item to render as thumbnailwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given CMS media item scaled to fit within the given bounds
-
getThumbnailUrl
Get the thumbnailUrl for a IIIF image identifier with default size.- Parameters:
baseUri- IIIF image identifier- Returns:
- Generated URL
-
getThumbnailUrl
Get the thumbnailUrl for a IIIF image identifier.- Parameters:
baseUri- IIIF image identifierwidth- thumbnail widthheight- thumbnail height- Returns:
- Generated URL
-
getSquareThumbnailUrl
Get the square thumbnailUrl for a IIIF image identifier with default size.- Parameters:
baseUri- IIIF image identifier- Returns:
- Generated URL
-
getSquareThumbnailUrl
Get the square thumbnailUrl for a IIIF image identifier.- Parameters:
baseUri- IIIF image identifiersize- thumbnail size- Returns:
- Generated URL
-
getThumbnailUrl
Get the thumbnailUrl for a IIIF image identifier.- Parameters:
baseUri- IIIF image identifierwidth- thumbnail widthheight- thumbnail heightsquare- true to deliver a square image- Returns:
- Generated URL
-
getCMSMediaImageApiUrl
- Parameters:
filename- CMS media file name for which to build the API URL- Returns:
- Generated URL
-
getCMSMediaImageApiUrl
-
getThumbnailUrl
Return the url to the image of the givenCMSMediaItem, fit into a box of the given width and height.- Parameters:
media- CMS media item to render as thumbnailwidth- maximum thumbnail width in pixelsheight- maximum thumbnail height in pixels- Returns:
- the thumbnail image URL for the given CMS media item scaled to fit within the given bounds
-
getSquareThumbnailUrl
Return the url to the image of the givenCMSMediaItemof 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:
optional- optional CMS media item to render as square thumbnailsize- width and height of the square image in pixels- Returns:
- the square thumbnail image URL for the given CMS media item at the given size
-
getSquareThumbnailUrl
Return the url to the image of the givenCMSMediaItemof 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:
media- CMS media item to render as square thumbnailsize- width and height of the square image in pixels- Returns:
- the square thumbnail image URL for the given CMS media item at the given size
-
getSquareThumbnailUrl
Return the url to the image of the givenCMSMediaItemof 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- optional CMS media item to render as square thumbnail- Returns:
- the square thumbnail image URL for the given CMS media item at the configured default size
-
getSquareThumbnailUrl
Return the url to the image of the givenCMSMediaItemof 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- CMS media item to render as square thumbnail- Returns:
- the square thumbnail image URL for the given CMS media item at the configured default size
-
isStaticImageResource
Tests whether the given url refers to an image within the viewer image resource folder.- Parameters:
thumbnailUrl- URL to test against the static images path- Returns:
- true if the url starts with the viewer url path to image resources
-