1. Project Clover database Mon Dec 22 2025 14:59:38 CST
  2. Package org.europa.together.business

File ImageProcessor.java

 

Code metrics

0
0
0
1
217
58
0
-
-
0
-

Classes

Class Line # Actions
ImageProcessor 23 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package org.europa.together.business;
2   
3    import java.awt.image.BufferedImage;
4    import java.io.File;
5    import java.util.List;
6    import org.apache.commons.imaging.common.ImageMetadata.ImageMetadataItem;
7    import org.apiguardian.api.API;
8    import static org.apiguardian.api.API.Status.STABLE;
9    import static org.apiguardian.api.API.Status.DEPRECATED;
10    import org.europa.together.exceptions.MisconfigurationException;
11    import org.springframework.stereotype.Component;
12   
13    /**
14    * A simple image processor with some useful basic functionality in
15    * applications. The implementation is a wrapper for the Java2D & imgscalr.
16    *
17    * @author elmar.dott@gmail.com
18    * @version 1.2
19    * @since 1.0
20    */
21    @API(status = STABLE, since = "1.0", consumers = "ImgSclrProcessor")
22    @Component
 
23    public interface ImageProcessor {
24   
25    /**
26    * Identifier for the given feature.
27    */
28    @API(status = STABLE, since = "1.2")
29    String FEATURE_ID = "CM-12";
30   
31    /**
32    * Supported JPEG file format.
33    */
34    @API(status = STABLE, since = "3.0")
35    String FORMAT_JPEG = "jpeg";
36   
37    /**
38    * Supported JPG file format.
39    */
40    @API(status = STABLE, since = "1.0")
41    String FORMAT_JPG = "jpg";
42   
43    /**
44    * Supported GIF file format.
45    */
46    @API(status = STABLE, since = "1.0")
47    String FORMAT_GIF = "gif";
48   
49    /**
50    * Supported PNG file format.
51    */
52    @API(status = STABLE, since = "1.0")
53    String FORMAT_PNG = "png";
54   
55    /**
56    * Load an BufferdImage. In te case an image is already loaded, this method
57    * overwrite the previous image.
58    *
59    * @param image as BufferdImage
60    * @return true on success
61    */
62    @API(status = STABLE, since = "1.0")
63    boolean loadImage(BufferedImage image);
64   
65    /**
66    * Load an image from a file. In te case an image is already loaded, this
67    * method overwrite the previous image.
68    *
69    * @param image as File
70    * @return true on success
71    */
72    @API(status = STABLE, since = "1.0")
73    boolean loadImage(File image);
74   
75    /**
76    * Test if an image is in the processor set.
77    *
78    * @return true on success
79    */
80    @API(status = DEPRECATED, since = "1.1")
81    boolean isImageSet();
82   
83    /**
84    * Save a modified image to a given name and path which is defined as file.
85    * Also the format (GIF, PNG, BMP or JPG) has to be defined. <br>
86    * <code>
87    * saveImage(renderedImage, new File("/my/file/image.png"), FORMAT_PNG);
88    * </code>
89    *
90    * @param renderedImage as BufferedImage
91    * @param file as File
92    * @param format as String
93    * @return true on success
94    * @throws org.europa.together.exceptions.MisconfigurationException case of
95    * error
96    */
97    @API(status = STABLE, since = "1.0")
98    boolean saveImage(BufferedImage renderedImage, File file, String format)
99    throws MisconfigurationException;
100   
101    /**
102    * A deep copy of a BufferdImage (CopyConstructor).
103    *
104    * @param source as BufferedImage
105    * @return a copied BufferedImage
106    */
107    @API(status = STABLE, since = "3.1")
108    BufferedImage copyImage(BufferedImage source);
109   
110    /**
111    * Get the height in pixel of the loaded image.
112    *
113    * @return height as int
114    */
115    @API(status = STABLE, since = "1.1")
116    int getHeight();
117   
118    /**
119    * Get the width in pixel of the loaded image.
120    *
121    * @return width as int
122    */
123    @API(status = STABLE, since = "1.1")
124    int getWidth();
125   
126    /**
127    * Calculate the size in bytes of the BufferdImage.
128    *
129    * @param image as BufferedImage
130    * @return imageSize as long
131    */
132    @API(status = STABLE, since = "1.1")
133    long getImageSize(BufferedImage image);
134   
135    /**
136    * Reset the loaded image.
137    */
138    @API(status = STABLE, since = "1.0")
139    void clearImage();
140   
141    /**
142    * Get from an given image an defined clipping. X and Y are the coordinates
143    * where the cropping starts. Height and width define an rectangle of the
144    * cropped area, which will be the new image.
145    *
146    * @param x as int
147    * @param y as int
148    * @param height as int
149    * @param width as int
150    * @return renderdImage as BufferedImage
151    * @throws org.europa.together.exceptions.MisconfigurationException case of
152    * error
153    */
154    @API(status = STABLE, since = "1.0")
155    BufferedImage crop(int x, int y, int height, int width)
156    throws MisconfigurationException;
157   
158    /**
159    * Flip the image horizontaly.
160    *
161    * @return renderdImage as BufferedImage
162    * @throws org.europa.together.exceptions.MisconfigurationException case of
163    * error
164    */
165    @API(status = STABLE, since = "1.0")
166    BufferedImage flipHorizontal() throws MisconfigurationException;
167   
168    /**
169    * Flip the image verticaly.
170    *
171    * @return renderdImage as BufferedImage
172    * @throws org.europa.together.exceptions.MisconfigurationException case of
173    * error
174    */
175    @API(status = STABLE, since = "1.0")
176    BufferedImage flipVertical() throws MisconfigurationException;
177   
178    /**
179    * Get the original loaded Image.
180    *
181    * @return image as BufferedImage
182    */
183    @API(status = STABLE, since = "1.0")
184    BufferedImage getImage();
185   
186    /**
187    * Resize an given image to a new Size. The new scale is given in percent
188    * and is be automatic calculated from the original image. The calculation
189    * is rounded, because of the mathematic operation as Integer.<br>
190    * calculation: int (original.size / 100) * percent<br>
191    *
192    * @param percentage as int
193    * @return renderdImage as BufferedImage
194    * @throws org.europa.together.exceptions.MisconfigurationException case of
195    * error
196    */
197    @API(status = STABLE, since = "1.0")
198    BufferedImage resize(int percentage) throws MisconfigurationException;
199   
200    /**
201    * Rotate the image 90 degree steps to the right side. Clockwise rotation.
202    *
203    * @return renderdImage as BufferedImage
204    * @throws org.europa.together.exceptions.MisconfigurationException case of
205    * error
206    */
207    @API(status = STABLE, since = "1.0")
208    BufferedImage rotateRight() throws MisconfigurationException;
209   
210    /**
211    * Get the full list of ImageMetaData.
212    *
213    * @return ImageMetaData as List
214    */
215    @API(status = STABLE, since = "2.1")
216    List<ImageMetadataItem> getMetaData();
217    }