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 StringThe CMYK color profilestatic final intDefines a number of a first page in a documentstatic final StringThe GRAY color profilestatic final floatDefines the default value for a non-transparent alpha layerstatic final StringDefines the sRGB ICC profile name used in OutputIntentstatic final StringThe RGB color profile -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainRGBColor(SignatureImageParameters parameters) This method verifies whether theparameterscontain at least one RGB colorstatic 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 booleanisGrayscale(Color color) This method verifies if the provided color lies in the grayscale color space (e.g.static 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
-
OPAQUE_VALUE
public static final float OPAQUE_VALUEDefines the default value for a non-transparent alpha layer- See Also:
-
CMYK_PROFILE_NAME
The CMYK color profile- See Also:
-
RGB_PROFILE_NAME
The RGB color profile- See Also:
-
GRAY_PROFILE_NAME
The GRAY color profile- See Also:
-
OUTPUT_INTENT_SRGB_PROFILE
Defines the sRGB ICC profile name used in OutputIntent- See Also:
-
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
-
isGrayscale
This method verifies if the provided color lies in the grayscale color space (e.g. WHITE, GRAY, BLACK)- Parameters:
color-Colorto check- Returns:
- TRUE if the color is a grayscale, FALSE otherwise
-
containRGBColor
This method verifies whether theparameterscontain at least one RGB color- Parameters:
parameters-SignatureImageParametersto check- Returns:
- TRUE if the given parameters contains at least one RGB color, FALSE otherwise
-