类 UImages

java.lang.Object
com.gdxsoft.easyweb.utils.UImages

public class UImages extends Object
The image utils
  • 字段详细资料

    • DEFAULT_QUALITY

      public static int DEFAULT_QUALITY
      Default image quality
  • 构造器详细资料

    • UImages

      public UImages()
  • 方法详细资料

    • appendLogo

      public static BufferedImage appendLogo(BufferedImage originalImage, BufferedImage logo, int logoMaxWidth, int logoMaxHeight) throws IOException
      Add a logo in the middle of a image
      参数:
      originalImage - The original image
      logo - The logo image
      logoMaxWidth - The logo max width
      logoMaxHeight - The logo max height
      返回:
      the image with the logo
      抛出:
      IOException
    • setRadius

      public static BufferedImage setRadius(BufferedImage srcImage, int radius, int border, int padding) throws IOException
      Set the rounded corners of the image
      参数:
      srcImage - The source image
      radius - The radius size
      border - The border width
      padding - The padding size
      返回:
      The result
      抛出:
      IOException
    • createBackground

      public static BufferedImage createBackground(BufferedImage srcImage, int radius, int border, int padding)
      Create a background image
      参数:
      srcImage - The source image
      radius - The radius size
      border - The border width
      padding - The padding size
      返回:
      The result
    • setClip

      public static BufferedImage setClip(BufferedImage srcImage, int radius)
      Set image radius
      参数:
      srcImage - The source image
      radius - The radius size
      返回:
      the result
    • createSmallImage

      public static String createSmallImage(String imgPath, int maxWidth, int maxHeight)
      Create the image thumbnail
      参数:
      imgPath - The image path and name
      maxwidth - The maximum width
      maxheight - The maximum height
      返回:
      The thumbnail image path and name
    • createSmallImage

      public static String createSmallImage(String imgPath, int maxWidth, int maxHeight, String outputExt, int quality)
      Create the image thumbnail
      参数:
      imgPath - The image path and name
      maxWidth - The maximum width
      maxHeight - The maximum height
      outputExt - The output image extension, e.g. jpg or png or webp ...
      quality - The image quality
      返回:
      The thumbnail image path and name
    • createResizedByJava

      public static File[] createResizedByJava(String imgPath, Dimension[] thumbnilsSize) throws Exception
      Create the image thumbnail (Using java)
      参数:
      imgPath - The image path and name
      thumbnilsSize - The thumbnail sizes (800x600, 400x300)...
      返回:
      The thumbnail files array
      抛出:
      Exception
    • getNewSize

      public static int[] getNewSize(BufferedImage bufferedImage, int maxWidth, int maxHeight)
      Get the image new size according the maximum width and maximum height limits
      参数:
      bufferedImage - The image
      maxWidth - Maximum width
      maxHeight - Maximum height
      返回:
      size (width , height)
    • createResized

      public static File[] createResized(String imgPath, Dimension[] thumbnilsSize) throws Exception
      Create the image thumbnails
      参数:
      imgPath - The image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      返回:
      The thumbnail files array
      抛出:
      Exception
    • createResized

      public static File[] createResized(String imgPath, Dimension[] thumbnilsSize, String outputExt, int quality) throws Exception
      Create the image thumbnails
      参数:
      imgPath - The image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      outputExt - output image ext, e.g. jpg or png
      quality - The image quality
      返回:
      The thumbnail files array
      抛出:
      Exception
    • checkImageMagick

      public static boolean checkImageMagick()
      Check whether using ImageMagick to resize image
      返回:
    • getImageMagick

      public static String getImageMagick() throws Exception
      Get the imageMagick's magick path
      返回:
      抛出:
      Exception
    • createResizedByImageMagick

      public static File[] createResizedByImageMagick(String imgPath, Dimension[] thumbnilsSize) throws Exception
      Create the image thumbnails (Using the ImageMagick)
      参数:
      imgPath - the image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      返回:
      The thumbnail files array
      抛出:
      Exception
    • getResizedImageName

      public static String getResizedImageName(Dimension size, String outputExt)
    • getResizedImageName

      public static String getResizedImageName(int width, int height, String outputExt)
    • createResizedByImageMagick

      public static File[] createResizedByImageMagick(String imgPath, Dimension[] thumbnilsSize, String outputExt, int quality) throws Exception
      Create the image thumbnails (Using the ImageMagick)
      参数:
      imgPath - the image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      outputExt - jpg or png or webp or heic ...
      quality - jpg quality
      返回:
      The thumbnail files array
      抛出:
      Exception
    • createResizedByThumbnails

      public static File[] createResizedByThumbnails(String imgPath, Dimension[] thumbnilsSize)
      Create the image thumbnails (using net.coobird.thumbnailator.Thumbnails)
      参数:
      imgPath - the image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      返回:
      The thumbnail files array
      抛出:
      Exception
    • createResizedByThumbnails

      public static File[] createResizedByThumbnails(String imgPath, Dimension[] thumbnilsSize, String outputExt, int quality)
      Create the image thumbnails (using net.coobird.thumbnailator.Thumbnails)
      参数:
      imgPath - the image path and name
      thumbnilsSize - The thumbnails size(800x600, 400x300)...
      outputExt - output image ext, e.g. jpg or png
      quality - the image quality
      返回:
      The thumbnail files array
      抛出:
      Exception
    • getBufferedImage

      public static BufferedImage getBufferedImage(String imgPath) throws IOException
      Get a BufferedImage from the image path and name
      参数:
      imgPath - the image path and name
      返回:
      BufferedImage the BufferedImage
      抛出:
      IOException
    • toBufferedImage

      public static BufferedImage toBufferedImage(Image image)
      Convert the Image to BufferedImage
      参数:
      image - The source image
      返回:
      BufferedImage the BufferedImage
    • imageSave

      public static void imageSave(BufferedImage buf, String name) throws IOException
      Save the BufferedImage to file (JPEG, 0.8)
      参数:
      buf - the BufferedImage
      name - the saved file path and name
      抛出:
      IOException
    • imageSave

      public static void imageSave(BufferedImage buf, File f1) throws IOException
      Save the BufferedImage to file (JPEG, 0.8)
      参数:
      buf - the BufferedImage
      f1 - the saved file
      抛出:
      IOException
    • createResizedCopy

      public static BufferedImage createResizedCopy(Image originalImage, int width, int height)
      Create an image according to the new size
      参数:
      originalImage - The original image
      width - The new width
      height - The new height
      返回:
      The new size image
    • createClipCopy

      public static BufferedImage createClipCopy(Image originalImage, int left, int top, int right, int bottom)
      Crop the image
      参数:
      originalImage - The original image
      left - The crop left
      top - The crop top
      right - The crop right
      bottom - The crop bottom
      返回:
      new BufferedImage
    • getBytes

      public static byte[] getBytes(BufferedImage bi, String imageType, float quality)
      Convert to BufferedImge to file buffer
      参数:
      bi - The BufferedImage
      imageType - The save to image type JPEG, PNG ...
      返回:
      The file buffer