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
Modifier and TypeFieldDescriptionstatic final String
The CMYK color profilestatic final int
Defines a number of a first page in a documentstatic final String
The GRAY color profilestatic final float
Defines the default value for a non-transparent alpha layerstatic final String
Defines the sRGB ICC profile name used in OutputIntentstatic final String
The RGB color profile -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containRGBColor
(SignatureImageParameters parameters) This method verifies whether theparameters
contain at least one RGB colorstatic int
drawSubtractionImage
(BufferedImage img1, BufferedImage img2, BufferedImage outImg) Draws the subtraction image and returns different pixels amountstatic AnnotationBox
getImageBoundaryBox
(DSSDocument imageDocument) Returns the AnnotationBox for the given image documentstatic float
getScaleFactor
(int zoom) Returns a coefficient applying to a signature field width/height calculationstatic boolean
imageDimensionsEqual
(BufferedImage img1, BufferedImage img2) Checks if the dimensions of the provided images is equalstatic boolean
imagesEqual
(BufferedImage img1, BufferedImage img2) Checks if the two given images are equalstatic boolean
isGrayscale
(Color color) This method verifies if the provided color lies in the grayscale color space (e.g.static boolean
isTransparent
(BufferedImage bufferedImage) Checks if the image has a transparent layerstatic ImageResolution
readDisplayMetadata
(DSSDocument image) Reads image's metadatastatic ImageResolution
secureReadMetadata
(SignatureImageParameters imageParameters) Reads image's metadata in a secure way.static BufferedImage
toBufferedImage
(DSSDocument imageDocument) Reads the image document and returns aBufferedImage
static BufferedImage
Reads image from InputStream.static DSSDocument
toDSSDocument
(BufferedImage bufferedImage) Transforms aBufferedImage
toDSSDocument
using in memory processingstatic DSSDocument
toDSSDocument
(BufferedImage bufferedImage, DSSResourcesHandler dssResourcesHandler) Transforms aBufferedImage
toDSSDocument
, 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
-
RGB_PROFILE_NAME
-
GRAY_PROFILE_NAME
-
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:
ImageResolution
metadata- Throws:
IOException
- in case of image reading error
-
readDisplayMetadata
Reads image's metadata- Parameters:
image
-DSSDocument
image to read metadata from- Returns:
ImageResolution
metadata- Throws:
IOException
- in case of image reading error
-
getImageBoundaryBox
Returns the AnnotationBox for the given image document- Parameters:
imageDocument
-DSSDocument
representing 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:
float
scale factor
-
toDSSDocument
Transforms aBufferedImage
toDSSDocument
using in memory processing- Parameters:
bufferedImage
-BufferedImage
to convert- Returns:
DSSDocument
-
toDSSDocument
public static DSSDocument toDSSDocument(BufferedImage bufferedImage, DSSResourcesHandler dssResourcesHandler) Transforms aBufferedImage
toDSSDocument
, using a providedDSSResourcesHandler
- Parameters:
bufferedImage
-BufferedImage
to convertdssResourcesHandler
-DSSResourcesHandler
- Returns:
DSSDocument
-
toBufferedImage
Reads the image document and returns aBufferedImage
- Parameters:
imageDocument
-DSSDocument
image 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
-InputStream
to 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
-BufferedImage
img2
-BufferedImage
- Returns:
- TRUE if the two images are equal, FALSE otherwise
-
imageDimensionsEqual
Checks if the dimensions of the provided images is equal- Parameters:
img1
-BufferedImage
img2
-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
-BufferedImage
to compareimg2
-BufferedImage
to compareoutImg
-BufferedImage
the output result (subtraction image)- Returns:
- amount of different pixels between two images
-
isGrayscale
-
containRGBColor
This method verifies whether theparameters
contain at least one RGB color- Parameters:
parameters
-SignatureImageParameters
to check- Returns:
- TRUE if the given parameters contains at least one RGB color, FALSE otherwise
-