Class ImageUtil


  • public class ImageUtil
    extends Object
    Utility methods for handling images
    Since:
    8.5.3
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • ImageUtil

        public ImageUtil()
    • Method Detail

      • saveImage

        public static void saveImage​(String content,
                                     File file)
                              throws IOException
        Saves an image into a given file in an image format
        Parameters:
        content - the content of the image Base64 encoded
        file - the output file
        Throws:
        IOException - in case of I/O error
      • cropImageToFile

        public static void cropImageToFile​(String content,
                                           ImageZone zone,
                                           File file)
                                    throws IOException
        Crops an area and stores it in a given .jpg file
        Parameters:
        content - the content of the source image Base64 encoded
        zone - the zone definition
        file - the output file
        Throws:
        IOException - an I/O error
      • cropImage

        public static BufferedImage cropImage​(BufferedImage originalImage,
                                              ImageZone zone)
        Crops an area from given image
        Parameters:
        originalImage - the original image
        zone - the zone definition
        Returns:
        the cropped image
      • cropCenterSquare

        public static BufferedImage cropCenterSquare​(BufferedImage originalImage,
                                                     int squareSize)
        Crops a square at the center of the given image
        Parameters:
        originalImage - the original image
        squareSize - size of the square
        Returns:
        the cropped square
      • pasteImage

        public static void pasteImage​(BufferedImage container,
                                      BufferedImage imageIn,
                                      float opaque,
                                      int x,
                                      int y)
        Prints the contents of imageIn on container the given opaque value
        Parameters:
        container - the bigger image
        imageIn - the image to print in
        opaque - and indication of how opaque must be the print
        x - left coordinate
        y - top coordinate
      • printFirstPage

        public static void printFirstPage​(File originalFile,
                                          String originalFileName,
                                          File out)
                                   throws IOException
        Prints the first page of the given file into the output as .jpg image
        Parameters:
        originalFile - the original file
        originalFileName - the original filename
        out - the output .jpg file
        Throws:
        IOException - a generic I/O error