Class AdaptiveImageHelper


  • public class AdaptiveImageHelper
    extends java.lang.Object
    Helper class for working with adaptive images.
    • Constructor Detail

      • AdaptiveImageHelper

        public AdaptiveImageHelper()
    • Method Detail

      • getQualityFromString

        public static AdaptiveImageHelper.Quality getQualityFromString​(java.lang.String imageQualityString)
        Lookup Quality value from a String.
        Parameters:
        imageQualityString - image quality
        Returns:
        a Quality value for the requested String if it exists.
      • scaleThisImage

        public Layer scaleThisImage​(Image image,
                                    int newWidth,
                                    int newHeight,
                                    Style style)
                             throws RepositoryException,
                                    java.io.IOException
        Scales the given image to the dimensions specified by newWidth and newHeight. The scaling algorithm will always scale the image in such a way that no white space will visible around the image. This means that in any case where the dimensions are not the exact aspect ratio of the image, some cropping will occur. Once the image has been cropped it will be adjusted so the center of the cropped dimension is still centered.
        Parameters:
        image - image
        newWidth - desired width
        newHeight - specify 0 to scale based on width and keep the current aspect ratio
        style - style data including user defined crop and rotation
        Returns:
        scaled (and/or cropped) image layer
        Throws:
        RepositoryException - if image can not be loaded
        java.io.IOException - if image can not be loaded
      • applyStyleDataToImage

        public Layer applyStyleDataToImage​(Image image,
                                           Style style)
                                    throws RepositoryException,
                                           java.io.IOException
        Applies style data to the given image, including crop and rotation.
        Parameters:
        image - image
        style - style
        Returns:
        Layer with style data applied.
        Throws:
        RepositoryException - if image can not be loaded
        java.io.IOException - if image can not be loaded
      • renderScaledPlaceholderImage

        public static Layer renderScaledPlaceholderImage​(int width,
                                                         int height)
        Renders a white rectangular layer with the given dimensions.
        Parameters:
        width - requested width
        height - requested height
        Returns:
        Empty layer of a given dimensions.