Class ServerImageHelper


  • public class ServerImageHelper
    extends Object
    Helper class for working with images
    • Field Detail

      • FILE_CONTENT_FILTER

        public static final org.apache.commons.io.filefilter.IOFileFilter FILE_CONTENT_FILTER
        A file filter which opens each file, accepting those whose content represent an image
    • Constructor Detail

      • ServerImageHelper

        public ServerImageHelper()
    • Method Detail

      • getActualSize

        public static Dimension getActualSize​(Dimension original,
                                              Integer requestedWidth,
                                              Integer requestedHeight)
        Return the size according to the original size and the optional requested dimensions
      • gradient

        public static BufferedImage gradient​(int width,
                                             int height,
                                             Color[] colors)
        Generates an image containing a gradient which passes through the given colors distributed evenly through the height
      • gradient

        public static BufferedImage gradient​(int width,
                                             int height,
                                             Color[] colors,
                                             float[] points)
        Generates an image containing a gradient which passes through the given colors at the given points
      • rescaleKeepingProportions

        public static Dimension rescaleKeepingProportions​(Dimension originalSize,
                                                          Dimension desiredSize,
                                                          @Nullable
                                                          Dimension maxSize)
        Calculates the rescaled image size for the given original and desired sizes. Also makes sure the desired size is never larger than the given maxSize.
      • thumbnailSize

        public static Dimension thumbnailSize​(Dimension originalSize,
                                              Dimension maxSize)
        Calculates the thumbnail size for the given original and maximum sizes
      • toThemeImageKind

        public static String toThemeImageKind​(ThemeImageType type)
        Return the value representing the ThemeImageKind in REST.