Class ImageUtil

java.lang.Object
com.vdoc.sdk.commons.utils.ImageUtil

public class ImageUtil extends Object
Image utility class
  • Field Details

  • Method Details

    • cropRatio

      public static BufferedImage cropRatio(BufferedImage image, double ratio, ImageUtil.CropRatioStrategy cropRatioStrategy)
      Crop an image to the target ratio
      Parameters:
      image - the source image
      ratio - the target ratio
      cropRatioStrategy - the zone to preserve
      Returns:
      the croped image
    • resizeImageToBestSize

      public static BufferedImage resizeImageToBestSize(BufferedImage image, float tagetMaxWidth, float tagetMaxHeight, boolean minimizeOnly, int colorType)
      resize an image to the greater size without distortion
      Parameters:
      image - initial image
      tagetMaxWidth - output max width
      tagetMaxHeight - output max height
      minimizeOnly - source image's size greater than output image
      colorType - an BufferedImage TYPE_ constant
      Returns:
      optimized resized image
    • resizeImageToBestSize

      public static BufferedImage resizeImageToBestSize(BufferedImage image, float tagetMaxWidth, float tagetMaxHeight, boolean minimizeOnly)
      resize an image to the greater size without distortion
      Parameters:
      image - initial image
      tagetMaxWidth - output max width
      tagetMaxHeight - output max height
      minimizeOnly - source image's size greater than output image
      Returns:
      optimized resized image
    • reziseImage

      public static BufferedImage reziseImage(BufferedImage image, float ratio, int colorType)
      resize image with specified ratio ( ratio invalid input: '<' 0 minimize ratio > 1 maximize )
      Parameters:
      image - initial image
      ratio - ( ratio invalid input: '<' 0 minimize ratio > 1 maximize )
      colorType - the color type
      Returns:
      resized image
    • canRead

      public static boolean canRead(String format)
      test if e type can be read
      Parameters:
      format - format name, Mime Type or suffix
      Returns:
      true if file type can be read
    • canWrite

      public static boolean canWrite(String format)
      test if e type can be write
      Parameters:
      format - format format name, Mime Type or suffix
      Returns:
      if file type can be write