Package com.logicaldoc.zonalocr
Class Util
- java.lang.Object
-
- com.logicaldoc.zonalocr.Util
-
public class Util extends Object
Utility methods for the Zonal OCR- Since:
- 8.4.2
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImage
cropImage(BufferedImage originalImage, Zone zone)
Crops an area from given imagestatic void
cropImageToFile(String content, Zone zone, File file)
Crops an area and stores it in a given .jpg filestatic String
encodeImage(File image)
Encodes in Bas64 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 .jpg formatstatic void
updateZoneSample(String sampleContent, Zone zone)
-
-
-
Method Detail
-
saveImage
public static void saveImage(String content, File file) throws IOException
Saves an image into a given file in .jpg 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, Zone 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 encodedoriginalFile
- The original image to croopzone
- the zone definitionfile
- the output file- Throws:
IOException
- an I/O error
-
cropImage
public static BufferedImage cropImage(BufferedImage originalImage, Zone zone)
Crops an area from given image- Parameters:
originalImage
- the original imagezone
- the zone definition- Returns:
- the cropped image
-
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 Bas64 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
-
-