Package org.europa.together.business
Interface ImageProcessor
- All Known Implementing Classes:
ImgSclrProcessor
@API(status=STABLE,
since="1.0",
consumers="ImgSclrProcessor")
@Component
public interface ImageProcessor
A simple image processor with some useful basic functionality in
applications. The implementation is a wrapper for the Java2D & imgscalr.
- Since:
- 1.0
- Version:
- 1.2
- Author:
- elmar.dott@gmail.com
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Reset the loaded image.crop
(int x, int y, int height, int width) Get from an given image an defined clipping.Flip the image horizontaly.Flip the image verticaly.int
Get the height in pixel of the loaded image.getImage()
Get the original loaded Image.long
getImageSize
(BufferedImage image) Calculate the size in bytes of the BufferdImage.List<org.apache.commons.imaging.common.ImageMetadata.ImageMetadataItem>
Get the full list of ImageMetaData.int
getWidth()
Get the width in pixel of the loaded image.boolean
Test if an image is in the processor set.boolean
loadImage
(BufferedImage image) Load an BufferdImage.boolean
Load an image from a file.resize
(int percentage) Resize an given image to a new Size.Rotate the image 90 degree steps to the right side.boolean
saveImage
(BufferedImage renderedImage, File file, String format) Save a modified image to a given name and path which is defined as file.
-
Field Details
-
FEATURE_ID
Identifier for the given feature.- See Also:
-
FORMAT_JPEG
Supported JPEG file format.- See Also:
-
FORMAT_JPG
Supported JPG file format.- See Also:
-
FORMAT_GIF
Supported GIF file format.- See Also:
-
FORMAT_PNG
Supported PNG file format.- See Also:
-
-
Method Details
-
loadImage
Load an BufferdImage. In te case an image is already loaded, this method overwrite the previous image.- Parameters:
image
- as BufferdImage- Returns:
- true on success
-
loadImage
Load an image from a file. In te case an image is already loaded, this method overwrite the previous image.- Parameters:
image
- as File- Returns:
- true on success
-
isImageSet
@API(status=DEPRECATED, since="1.1") boolean isImageSet()Test if an image is in the processor set.- Returns:
- true on success
-
saveImage
@API(status=STABLE, since="1.0") boolean saveImage(BufferedImage renderedImage, File file, String format) throws MisconfigurationException Save a modified image to a given name and path which is defined as file. Also the format (GIF, PNG, BMP or JPG) has to be defined.
saveImage(renderedImage, new File("/my/file/image.png"), FORMAT_PNG);
- Parameters:
renderedImage
- as BufferedImagefile
- as Fileformat
- as String- Returns:
- true on success
- Throws:
MisconfigurationException
-
getHeight
@API(status=STABLE, since="1.1") int getHeight()Get the height in pixel of the loaded image.- Returns:
- height as int
-
getWidth
@API(status=STABLE, since="1.1") int getWidth()Get the width in pixel of the loaded image.- Returns:
- width as int
-
getImageSize
Calculate the size in bytes of the BufferdImage.- Parameters:
image
- as BufferedImage- Returns:
- imageSize as long
-
clearImage
@API(status=STABLE, since="1.0") void clearImage()Reset the loaded image. -
crop
@API(status=STABLE, since="1.0") BufferedImage crop(int x, int y, int height, int width) throws MisconfigurationException Get from an given image an defined clipping. X and Y are the coordinates where the cropping starts. Height and width define an rectangle of the cropped area, which will be the new image.- Parameters:
x
- as inty
- as intheight
- as intwidth
- as int- Returns:
- renderdImage as BufferedImage
- Throws:
MisconfigurationException
-
flipHorizontal
Flip the image horizontaly.- Returns:
- renderdImage as BufferedImage
- Throws:
MisconfigurationException
-
flipVertical
Flip the image verticaly.- Returns:
- renderdImage as BufferedImage
- Throws:
MisconfigurationException
-
getImage
Get the original loaded Image.- Returns:
- image as BufferedImage
-
resize
@API(status=STABLE, since="1.0") BufferedImage resize(int percentage) throws MisconfigurationException Resize an given image to a new Size. The new scale is given in percent and is be automatic calculated from the original image. The calculation is rounded, because of the mathematic operation as Integer.
calculation: int (original.size / 100) * percent- Parameters:
percentage
- as int- Returns:
- renderdImage as BufferedImage
- Throws:
MisconfigurationException
-
rotateRight
Rotate the image 90 degree steps to the right side. Clockwise rotation.- Returns:
- renderdImage as BufferedImage
- Throws:
MisconfigurationException
-
getMetaData
@API(status=STABLE, since="2.1") List<org.apache.commons.imaging.common.ImageMetadata.ImageMetadataItem> getMetaData()Get the full list of ImageMetaData.- Returns:
- ImageMetaData as List
-