Class ImageTransformationUtility

java.lang.Object
io.jans.util.image.ImageTransformationUtility

public final class ImageTransformationUtility extends Object
Utility to do high quality image resize
Author:
Yuriy Movchan Date: 11.03.2010
  • Method Details

    • scaleImage

      public static BufferedImage scaleImage(BufferedImage img, int maxWidth, int maxHeight)
      Parameters:
      img - the original image to be scaled
      maxWidth - the desired width of the scaled instance, in pixels
      maxHeight - the desired height of the scaled instance, in pixels
      Returns:
      a scaled version of the original BufferedImage
    • scaleImage

      public static BufferedImage scaleImage(BufferedImage img, int maxWidth, int maxHeight, Object hint, boolean higherQuality)
      Convenience method that returns a scaled instance of the provided BufferedImage.
      Parameters:
      img - the original image to be scaled
      maxWidth - the desired width of the scaled instance, in pixels
      maxHeight - the desired height of the scaled instance, in pixels
      hint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)
      higherQuality - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, where targetWidth or targetHeight is smaller than the original dimensions, and generally only when the BILINEAR hint is specified)
      Returns:
      a scaled version of the original BufferedImage