Interface ImageUtilsServiceLocal
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbyte[]downloadImage(String sessionId, URI uri) Download an image from URL.byte[]downloadImage(URI uri) Download an image from URL.getImageInfoOfMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Get image info of the media object, such as width, height, resolution etc.getMediaAssetImageInfo(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset) Get image info of the first valid Media Object of the Media Asset, such as width, height, resolution etc.getMediaAssetImageInfo(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, ImageSource imageSource) Get image info of the first valid media object of the media asset, such as width, height, resolution etc.byte[]getPreviewOfMediaAsset(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean fallbackToDummyImage, ImageSource imageSource) Gets a media asset preview.byte[]getPreviewOfMediaAsset(String sessionId, com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean fallbackToDummyImage, ImageSource imageSource) Gets a preview a media asset.byte[]getPreviewOfMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, int width, int height, ImageSource imageSource) Get a preview a media object.byte[]getPreviewOfMediaObject(String sessionId, com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, int width, int height, ImageSource imageSource) Get a preview a media object.byte[]readMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Reads an image from the media object.byte[]readMediaObject(String sessionId, com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Reads an image from a media object.byte[]scaleProportional(byte[] src, int width, int height) Scales an image proportionally to fit within the specified width and height.
-
Method Details
-
getPreviewOfMediaAsset
byte[] getPreviewOfMediaAsset(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean fallbackToDummyImage, ImageSource imageSource) Gets a media asset preview.This iterates the list of media objects and try to read the images from file or URL resource. The first resource that can be read and parsed into an image object will be returned.
If no preview was found and fallbackToDummyImage is true a dummy preview will be generated (but never cached).
If there are authentication problems with this method, please use the variant of this method with sessionId parameter
- Parameters:
mediaAsset- The MediaAsset to process.prefixForCache- A prefix for the key used for caching the preview.width- preview width (min. 100px)height- preview height (min. 100px)fallbackToDummyImage- Generate dummy preview if no preview was found.imageSource- Source of image from MediaObject.- Returns:
- preview of first valid MediaObject or dummy preview (fallbackToDummyImage=true) or null.
-
getPreviewOfMediaAsset
byte[] getPreviewOfMediaAsset(String sessionId, com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean fallbackToDummyImage, ImageSource imageSource) Gets a preview a media asset.This iterates the list of media objects and try to read the images from file or URL resource. The first resource that can be read and parsed into an image object will be returned.
If no preview was found and fallbackToDummyImage is true a dummy preview will be generated (but never cached).
- Parameters:
sessionId- The current session identifier.mediaAsset- The MediaAsset to process.prefixForCache- A prefix for the key used for caching the preview.width- Preview width (min. 100px)height- Preview height (min. 100px)fallbackToDummyImage- Generate dummy preview if no preview was found.imageSource- Source of image from MediaObject.- Returns:
- preview of first valid MediaObject or dummy preview (fallbackToDummyImage=true) or null.
-
getPreviewOfMediaObject
byte[] getPreviewOfMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, int width, int height, ImageSource imageSource) Get a preview a media object.If there are authentication problems with this method, please use the variant of this method with sessionId parameter
- Parameters:
mediaObject- The mediaObject to process.width- Preview width (min. 100px)height- Preview height (min. 100px)imageSource- Source of image from MediaObject.- Returns:
- Preview of the Media Object or null
-
getPreviewOfMediaObject
byte[] getPreviewOfMediaObject(String sessionId, com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, int width, int height, ImageSource imageSource) Get a preview a media object.- Parameters:
sessionId- The current sessionIdmediaObject- The mediaObject to process.width- Preview width (min. 100px)height- Preview height (min. 100px)imageSource- Source of image from the media object.- Returns:
- Preview of the Media Object or null
-
readMediaObject
byte[] readMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Reads an image from the media object.If there are authentication problems with this method, please use the variant of this method with sessionId parameter
- Parameters:
mediaObject- The media object to process.imageSource- Source of image from the media object.- Returns:
- The byte array - or an empty array if anything fails.
-
readMediaObject
byte[] readMediaObject(String sessionId, com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Reads an image from a media object.- Parameters:
sessionId- current session identifiermediaObject- The media object to process.imageSource- Source of image from media object.- Returns:
- The byte array - or an empty array if anything fails.
-
downloadImage
Download an image from URL.
Connect and read timeouts can be set via system properties: HTTP_CONNECT_TIMEOUT, HTTP_READ_TIMEOUT.If there are authentication problems with this method, please use the variant of this method with sessionId parameter
- Parameters:
uri- URI of the resource that you want to load- Returns:
- the byte array - or an empty array if anything fails.
-
downloadImage
Download an image from URL.
Connect and read timeouts can be set via system properties: HTTP_CONNECT_TIMEOUT, HTTP_READ_TIMEOUT.- Parameters:
sessionId- The current session identifieruri- URI of the resource that you want to load- Returns:
- The byte array - or an empty array if anything fails.
-
getMediaAssetImageInfo
Optional<ImageUtilsServiceLocal.ImageInfo> getMediaAssetImageInfo(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset) Get image info of the first valid Media Object of the Media Asset, such as width, height, resolution etc.- Parameters:
mediaAsset- The Media Asset- Returns:
- Optional containing image information - or an empty one if none could be found
-
getMediaAssetImageInfo
Optional<ImageUtilsServiceLocal.ImageInfo> getMediaAssetImageInfo(com.priint.pubserver.plugin.entitydata.MediaAsset mediaAsset, ImageSource imageSource) Get image info of the first valid media object of the media asset, such as width, height, resolution etc.- Parameters:
mediaAsset- The media assetimageSource- Source of image from media object.- Returns:
- Optional containing image information - or an empty one if none could be found
-
getImageInfoOfMediaObject
Optional<ImageUtilsServiceLocal.ImageInfo> getImageInfoOfMediaObject(com.priint.pubserver.plugin.entitydata.MediaObject mediaObject, ImageSource imageSource) Get image info of the media object, such as width, height, resolution etc.- Parameters:
mediaObject- The media objectimageSource- Source of image from media object- Returns:
- Optional containing image information - or an empty one if none could be found
-
scaleProportional
byte[] scaleProportional(byte[] src, int width, int height) Scales an image proportionally to fit within the specified width and height.The method takes a source image in the form of a byte array and resizes it to fit within the specified dimensions while maintaining the original aspect ratio. It supports common image formats such as JPEG, PNG, GIF ....
- Parameters:
src- the byte array containing the source image datawidth- the maximum width of the scaled image, in pixelsheight- the maximum height of the scaled image, in pixels- Returns:
- a byte array containing the scaled image data
-