Package eu.europa.esig.dss.pdf.visible
Class ImageUtils
java.lang.Object
eu.europa.esig.dss.pdf.visible.ImageUtils
Static utilities for image creation and processing
- Author:
- pakeyser
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefines a number of a first page in a document -
Method Summary
Modifier and TypeMethodDescriptionstatic intdrawSubtractionImage(BufferedImage img1, BufferedImage img2, BufferedImage outImg) Draws the subtraction image and returns different pixels amountstatic AnnotationBoxgetImageBoundaryBox(DSSDocument imageDocument) Returns the AnnotationBox for the given image documentstatic floatgetScaleFactor(int zoom) Returns a coefficient applying to a signature field width/height calculationstatic booleanimageDimensionsEqual(BufferedImage img1, BufferedImage img2) Checks if the dimensions of the provided images is equalstatic booleanimagesEqual(BufferedImage img1, BufferedImage img2) Checks if the two given images are equalstatic booleanisTransparent(BufferedImage bufferedImage) Checks if the image has a transparent layerstatic ImageResolutionreadDisplayMetadata(DSSDocument image) Reads image's metadatastatic ImageResolutionsecureReadMetadata(SignatureImageParameters imageParameters) Reads image's metadata in a secure way.static BufferedImagetoBufferedImage(DSSDocument imageDocument) Reads the image document and returns aBufferedImagestatic BufferedImageReads image from InputStream.static DSSDocumenttoDSSDocument(BufferedImage bufferedImage) Transforms aBufferedImagetoDSSDocumentusing in memory processingstatic DSSDocumenttoDSSDocument(BufferedImage bufferedImage, DSSResourcesHandler dssResourcesHandler) Transforms aBufferedImagetoDSSDocument, using a providedDSSResourcesHandler
-
Field Details
-
DEFAULT_FIRST_PAGE
public static final int DEFAULT_FIRST_PAGEDefines a number of a first page in a document- See Also:
-
-
Method Details
-
secureReadMetadata
public static ImageResolution secureReadMetadata(SignatureImageParameters imageParameters) throws IOException Reads image's metadata in a secure way. If metadata is not accessible fromimage, returns values fromimageParameters- Parameters:
imageParameters-SignatureImageParameters- Returns:
ImageResolutionmetadata- Throws:
IOException- in case of image reading error
-
readDisplayMetadata
Reads image's metadata- Parameters:
image-DSSDocumentimage to read metadata from- Returns:
ImageResolutionmetadata- Throws:
IOException- in case of image reading error
-
getImageBoundaryBox
Returns the AnnotationBox for the given image document- Parameters:
imageDocument-DSSDocumentrepresenting an image- Returns:
AnnotationBox
-
getScaleFactor
public static float getScaleFactor(int zoom) Returns a coefficient applying to a signature field width/height calculation- Parameters:
zoom- - zoom value to compute scale factor from- Returns:
floatscale factor
-
toDSSDocument
Transforms aBufferedImagetoDSSDocumentusing in memory processing- Parameters:
bufferedImage-BufferedImageto convert- Returns:
DSSDocument
-
toDSSDocument
public static DSSDocument toDSSDocument(BufferedImage bufferedImage, DSSResourcesHandler dssResourcesHandler) Transforms aBufferedImagetoDSSDocument, using a providedDSSResourcesHandler- Parameters:
bufferedImage-BufferedImageto convertdssResourcesHandler-DSSResourcesHandler- Returns:
DSSDocument
-
toBufferedImage
Reads the image document and returns aBufferedImage- Parameters:
imageDocument-DSSDocumentimage document to read- Returns:
BufferedImage- Throws:
IOException- - in case of InputStream reading error
-
toBufferedImage
Reads image from InputStream. Detects and converts CMYK images to RGB if needed- Parameters:
is-InputStreamto read the image from- Returns:
BufferedImage- Throws:
IOException- - in case of InputStream reading error
-
isTransparent
Checks if the image has a transparent layer- Parameters:
bufferedImage-BufferedImage- Returns:
- TRUE if the image has a transparent layer, FALSE otherwise
-
imagesEqual
Checks if the two given images are equal- Parameters:
img1-BufferedImageimg2-BufferedImage- Returns:
- TRUE if the two images are equal, FALSE otherwise
-
imageDimensionsEqual
Checks if the dimensions of the provided images is equal- Parameters:
img1-BufferedImageimg2-BufferedImage- Returns:
- TRUE if the size dimensions of both images is equal, FALSE otherwise
-
drawSubtractionImage
public static int drawSubtractionImage(BufferedImage img1, BufferedImage img2, BufferedImage outImg) Draws the subtraction image and returns different pixels amount- Parameters:
img1-BufferedImageto compareimg2-BufferedImageto compareoutImg-BufferedImagethe output result (subtraction image)- Returns:
- amount of different pixels between two images
-