Package com.logicaldoc.core.imaging
Class ImageUtil
- java.lang.Object
-
- com.logicaldoc.core.imaging.ImageUtil
-
public class ImageUtil extends Object
Utility methods for handling images- Since:
- 8.5.3
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description ImageUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImage
cropCenterSquare(BufferedImage originalImage, int squareSize)
Crops a square at the center of the given imagestatic BufferedImage
cropImage(BufferedImage originalImage, ImageZone zone)
Crops an area from given imagestatic void
cropImageToFile(String content, ImageZone zone, File file)
Crops an area and stores it in a given .jpg filestatic String
encodeImage(File image)
Encodes in Base64 the given image filestatic void
pasteImage(BufferedImage container, BufferedImage imageIn, float opaque, int x, int y)
Prints the contents of imageIn on container the given opaque valuestatic void
printFirstPage(File originalFile, String originalFileName, File out)
Prints the first page of the given file into the output as .jpg imagestatic void
saveImage(String content, File file)
Saves an image into a given file in an image format
-
-
-
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 encodedfile
- 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 encodedzone
- the zone definitionfile
- 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 imagezone
- 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 imagesquareSize
- 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 imageimageIn
- the image to print inopaque
- and indication of how opaque must be the printx
- left coordinatey
- top coordinate
-
encodeImage
public static String encodeImage(File image) throws FileNotFoundException, IOException
Encodes in Base64 the given image file- Parameters:
image
- the image to encode- Returns:
- the encoded image
- Throws:
IOException
- error in the elaboration of the imageFileNotFoundException
- error accessing the file
-
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 fileoriginalFileName
- the original filenameout
- the output .jpg file- Throws:
IOException
- a generic I/O error
-
-