Class ImageUtils
System properties associated with thiks class.
- com.priint.pubserver.util.ImageUtils.HTTP_CONNECT_TIMEOUT
Timeout in msec for HTTP connections triggered byImageUtils()
Default: 5000 - com.priint.pubserver.util.ImageUtils.HTTP_READ_TIMEOUT
Timeout in msec for HTTP responses triggered byImageUtils()
Default: 10000 - com.priint.pubserver.util.ImageUtils.HTTPS_ALLOW_INSECURE
Flag to handle secure connections. If set to 1 HTTPS connections triggered byImageUtils()will not be rejected even if certificate in invalid or channel can not be assured to be secure. Only use this in testing mode!
Default: 0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.System property to add the user agent to the requeststatic final StringDeprecated.System property to overwrite the default connection timeoutstatic final StringDeprecated.System property to overwrite the default read timeoutstatic final StringDeprecated.System property to overwrite the default flag to handle secure connections.static final StringDeprecated.System property to overwrite the default SSL context used.static final StringDeprecated.Metadata key for the image color depth property.static final StringDeprecated.Metadata key for the image height property.static final StringDeprecated.Metadata key for the image resolution property.static final StringDeprecated.Metadata key for the image width property. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]downloadImage(String sessionId, URI uri) Deprecated.Download an image from URL.static byte[]downloadImage(URI uri) Deprecated.Download an image from URL.static BufferedImagegetBufferedImage(byte[] bytes) Deprecated.This method creates a buffered image from a given byte[] using theBufferedImage.TYPE_3BYTE_BGRcolor modelstatic BufferedImagegetBufferedImage(byte[] bytes, int imageType) Deprecated.Creates a buffered image from the given byte[] using the color model provided.getImageInfoOfMediaObject(MediaObject mediaObject, String mediaObjectSourceOrder) Deprecated.Get image info a MediaObject, such as width, height, resolution etc.getMediaAssetImageInfo(MediaAsset mediaAsset) Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.getMediaAssetImageInfo(MediaAsset mediaAsset, String mediaObjectSourceOrder) Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.getMediaAssetImageInfo(MediaAsset mediaAsset, String mediaObjectFilePath, String mediaObjectSourceOrder) Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.static byte[]getPreviewOfMediaAsset(MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage) Deprecated.Get a preview a MediaAsset.static byte[]getPreviewOfMediaAsset(MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaAsset.static byte[]getPreviewOfMediaAsset(String sessionId, MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage) Deprecated.Get a preview a MediaAsset.static byte[]getPreviewOfMediaAsset(String sessionId, MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaAsset.static byte[]getPreviewOfMediaObject(MediaObject mediaObject, int width, int height, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaObject.static byte[]getPreviewOfMediaObject(String sessionId, MediaObject mediaObject, int width, int height, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaObject.static byte[]readMediaObject(MediaObject mediaObject, String mediaObjectSourceOrder) Deprecated.Reads an image from file or from the network.static byte[]readMediaObject(String sessionId, MediaObject mediaObject, String mediaObjectSourceOrder) Deprecated.Reads an image from file or from the network.static booleanDeprecated.please use Apache commons FileUtils for similar functionality.static byte[]scaleProportional(byte[] src, int width, int height) Deprecated.
-
Field Details
-
IMAGE_HEIGHT_METADATA_NAME
Deprecated.Metadata key for the image height property.- See Also:
-
IMAGE_WIDTH_METADATA_NAME
Deprecated.Metadata key for the image width property.- See Also:
-
IMAGE_RESOLUTION_METADATA_NAME
Deprecated.Metadata key for the image resolution property.- See Also:
-
IMAGE_COLORDEPTH_METADATA_NAME
Deprecated.Metadata key for the image color depth property.- See Also:
-
HTTP_CONNECT_TIMEOUT_PROP
Deprecated.System property to overwrite the default connection timeout -
HTTP_READ_TIMEOUT_PROP
Deprecated.System property to overwrite the default read timeout -
HTTPS_ALLOW_INSECURE_PROP
Deprecated.System property to overwrite the default flag to handle secure connections. -
HTTPS_CONTEXT_PROP
Deprecated.System property to overwrite the default SSL context used. -
HTTP_CONNECT_ADD_USER_AGENT
Deprecated.System property to add the user agent to the request
-
-
Method Details
-
getPreviewOfMediaAsset
public static byte[] getPreviewOfMediaAsset(MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage) Deprecated.Get a preview a MediaAsset.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.
Previews will be cached if prefixForCache is set to a non-empty string.
If no preview was found and defaultToDummyImage 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
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)defaultToDummyImage- Generate dummy preview if no preview was found.- Returns:
- preview of first valid MediaObject or dummy preview (makeEmptyImage=true) or null result (if not null) is in PNG format.
-
getPreviewOfMediaAsset
public static byte[] getPreviewOfMediaAsset(String sessionId, MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage) Deprecated.Get a preview a MediaAsset.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.
Previews will be cached if prefixForCache is set to a non-empty string.
If no preview was found and defaultToDummyImage is true a dummy preview will be generated (but never cached).
- Parameters:
sessionId- current sessionId.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)defaultToDummyImage- Generate dummy preview if no preview was found.- Returns:
- preview of first valid MediaObject or dummy preview (makeEmptyImage=true) or null result (if not null) is in PNG format.
-
getPreviewOfMediaAsset
public static byte[] getPreviewOfMediaAsset(MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaAsset.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.
Previews will be cached if prefixForCache is set to a non-empty string.
If no preview was found and defaultToDummyImage 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)defaultToDummyImage- Generate dummy preview if no preview was found.- Returns:
- preview of first valid MediaObject or dummy preview (makeEmptyImage=true) or null result (if not null) is in PNG format.
-
getPreviewOfMediaAsset
public static byte[] getPreviewOfMediaAsset(String sessionId, MediaAsset mediaAsset, String prefixForCache, int width, int height, boolean defaultToDummyImage, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaAsset.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.
Previews will be cached if prefixForCache is set to a non-empty string.
If no preview was found and defaultToDummyImage is true a dummy preview will be generated (but never cached).
- Parameters:
sessionId- current sessionId.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)defaultToDummyImage- Generate dummy preview if no preview was found.- Returns:
- preview of first valid MediaObject or dummy preview (makeEmptyImage=true) or null result (if not null) is in PNG format.
-
getPreviewOfMediaObject
public static byte[] getPreviewOfMediaObject(MediaObject mediaObject, int width, int height, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaObject.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)mediaObjectSourceOrder-- Returns:
- preview of MediaObject or null
-
getPreviewOfMediaObject
public static byte[] getPreviewOfMediaObject(String sessionId, MediaObject mediaObject, int width, int height, String mediaObjectSourceOrder) Deprecated.Get a preview a MediaObject.- Parameters:
sessionId- The current sessionIdmediaObject- The mediaObject to process.width- preview width (min. 100px)height- preview height (min. 100px)mediaObjectSourceOrder-- Returns:
- preview of MediaObject or null
-
getMediaAssetImageInfo
public static Map<String,Object> getMediaAssetImageInfo(MediaAsset mediaAsset, String mediaObjectFilePath, String mediaObjectSourceOrder) Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.- Parameters:
mediaAsset- the MediaAssetmediaObjectFilePath- an optional path, if set (i.e. non null) the information is read from this particular file rather than from just the first MediaObject found.mediaObjectSourceOrder- order for getting preview (by defualt preview is taken from URL, if failed then looks for path)- Returns:
- certain image information - or null
-
getMediaAssetImageInfo
public static Map<String,Object> getMediaAssetImageInfo(MediaAsset mediaAsset, String mediaObjectSourceOrder) Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.- Parameters:
mediaAsset- the MediaAssetmediaObjectSourceOrder- order for getting preview (by defualt preview is taken from URL, if failed then looks for path)- Returns:
- certain image information - or null
-
getMediaAssetImageInfo
Deprecated.Get image info of the first valid MediaObject of a MediaAsset, such as width, height, resolution etc.- Parameters:
mediaAsset- the MediaAsset- Returns:
- certain image information - or null
-
getImageInfoOfMediaObject
public static Map<String,Object> getImageInfoOfMediaObject(MediaObject mediaObject, String mediaObjectSourceOrder) Deprecated.Get image info a MediaObject, such as width, height, resolution etc.- Parameters:
mediaObject-mediaObjectSourceOrder- order for getting preview (by defualt preview is taken from URL, if failed then looks for path)- Returns:
- certain image information - or null
-
readMediaObject
Deprecated.Reads an image from file or from the network.If there are authentication problems with this method, please use the variant of this method with sessionId parameter
- Parameters:
mediaObject-mediaObjectSourceOrder-- Returns:
-
readMediaObject
public static byte[] readMediaObject(String sessionId, MediaObject mediaObject, String mediaObjectSourceOrder) Deprecated.Reads an image from file or from the network.- Parameters:
sessionId- current session identifiermediaObject-mediaObjectSourceOrder-- Returns:
-
downloadImage
Deprecated.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-- Returns:
- the byte array - or an empty array if anything fails.
-
downloadImage
Deprecated.Download an image from URL.
Connect and read timeouts can be set via system properties:- Parameters:
sessionId- current session identifieruri-- Returns:
- the byte array - or an empty array if anything fails.
-
scaleProportional
public static byte[] scaleProportional(byte[] src, int width, int height) Deprecated.- Parameters:
src- image (bmp, png, jpeg, gif, tiff) as byteswidth-height-- Returns:
-
saveBytes
Deprecated.please use Apache commons FileUtils for similar functionality.Save byte array to a file- Parameters:
file-bytes-- Returns:
- true if data was successfully saved to file
-
getBufferedImage
Deprecated.This method creates a buffered image from a given byte[] using theBufferedImage.TYPE_3BYTE_BGRcolor model- Parameters:
bytes- bytes to be converted into BufferedImage- Returns:
- BufferedImage
-
getBufferedImage
Deprecated.Creates a buffered image from the given byte[] using the color model provided.- Parameters:
bytes- bytes to be converted into BufferedImageimageType- color model, seeBufferedImage- Returns:
- BufferedImage
-