Class ImageUtils

java.lang.Object
com.priint.pubserver.util.ImageUtils

@Deprecated public class ImageUtils extends Object
Deprecated.
Various static helper methods for Images

System properties associated with thiks class.

  • com.priint.pubserver.util.ImageUtils.HTTP_CONNECT_TIMEOUT
    Timeout in msec for HTTP connections triggered by ImageUtils()
    Default: 5000
  • com.priint.pubserver.util.ImageUtils.HTTP_READ_TIMEOUT
    Timeout in msec for HTTP responses triggered by ImageUtils()
    Default: 10000
  • com.priint.pubserver.util.ImageUtils.HTTPS_ALLOW_INSECURE
    Flag to handle secure connections. If set to 1 HTTPS connections triggered by ImageUtils() 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
This class is deprecated. You can use ImageUtilsServiceLocal from PubServerAPI. You can get an instance of this class by calling: PlannerEngineServiceLocator.INSTANCE.getImageUtilsServiceLocal()
  • Field Details

    • IMAGE_HEIGHT_METADATA_NAME

      public static final String IMAGE_HEIGHT_METADATA_NAME
      Deprecated.
      Metadata key for the image height property.
      See Also:
    • IMAGE_WIDTH_METADATA_NAME

      public static final String IMAGE_WIDTH_METADATA_NAME
      Deprecated.
      Metadata key for the image width property.
      See Also:
    • IMAGE_RESOLUTION_METADATA_NAME

      public static final String IMAGE_RESOLUTION_METADATA_NAME
      Deprecated.
      Metadata key for the image resolution property.
      See Also:
    • IMAGE_COLORDEPTH_METADATA_NAME

      public static final String IMAGE_COLORDEPTH_METADATA_NAME
      Deprecated.
      Metadata key for the image color depth property.
      See Also:
    • HTTP_CONNECT_TIMEOUT_PROP

      public static final String HTTP_CONNECT_TIMEOUT_PROP
      Deprecated.
      System property to overwrite the default connection timeout
    • HTTP_READ_TIMEOUT_PROP

      public static final String HTTP_READ_TIMEOUT_PROP
      Deprecated.
      System property to overwrite the default read timeout
    • HTTPS_ALLOW_INSECURE_PROP

      public static final String HTTPS_ALLOW_INSECURE_PROP
      Deprecated.
      System property to overwrite the default flag to handle secure connections.
    • HTTPS_CONTEXT_PROP

      public static final String HTTPS_CONTEXT_PROP
      Deprecated.
      System property to overwrite the default SSL context used.
    • HTTP_CONNECT_ADD_USER_AGENT

      public static final String 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 sessionId
      mediaObject - 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 MediaAsset
      mediaObjectFilePath - 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 MediaAsset
      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)
      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

      public static byte[] readMediaObject(MediaObject mediaObject, String mediaObjectSourceOrder)
      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 identifier
      mediaObject -
      mediaObjectSourceOrder -
      Returns:
    • downloadImage

      public static byte[] downloadImage(URI uri)
      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

      public static byte[] downloadImage(String sessionId, URI uri)
      Deprecated.
      Download an image from URL.
      Connect and read timeouts can be set via system properties:
      Parameters:
      sessionId - current session identifier
      uri -
      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 bytes
      width -
      height -
      Returns:
    • saveBytes

      @Deprecated public static boolean saveBytes(File file, byte[] bytes)
      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

      public static BufferedImage getBufferedImage(byte[] bytes)
      Deprecated.
      This method creates a buffered image from a given byte[] using the BufferedImage.TYPE_3BYTE_BGR color model
      Parameters:
      bytes - bytes to be converted into BufferedImage
      Returns:
      BufferedImage
    • getBufferedImage

      public static BufferedImage getBufferedImage(byte[] bytes, int imageType)
      Deprecated.
      Creates a buffered image from the given byte[] using the color model provided.
      Parameters:
      bytes - bytes to be converted into BufferedImage
      imageType - color model, see BufferedImage
      Returns:
      BufferedImage