1. Project Clover database Wed Jan 17 2024 23:40:18 CST
  2. Package org.europa.together.business

File ImageProcessor.java

 

Code metrics

0
0
0
1
202
56
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
95    */
96    @API(status = STABLE, since = "1.0")
97    boolean saveImage(BufferedImage renderedImage, File file, String format)
98    throws MisconfigurationException;
99   
100    /**
101    * Get the height in pixel of the loaded image.
102    *
103    * @return height as int
104    */
105    @API(status = STABLE, since = "1.1")
106    int getHeight();
107   
108    /**
109    * Get the width in pixel of the loaded image.
110    *
111    * @return width as int
112    */
113    @API(status = STABLE, since = "1.1")
114    int getWidth();
115   
116    /**
117    * Calculate the size in bytes of the BufferdImage.
118    *
119    * @param image as BufferedImage
120    * @return imageSize as long
121    */
122    @API(status = STABLE, since = "1.1")
123    long getImageSize(BufferedImage image);
124   
125    /**
126    * Reset the loaded image.
127    */
128    @API(status = STABLE, since = "1.0")
129    void clearImage();
130   
131    /**
132    * Get from an given image an defined clipping. X and Y are the coordinates
133    * where the cropping starts. Height and width define an rectangle of the
134    * cropped area, which will be the new image.
135    *
136    * @param x as int
137    * @param y as int
138    * @param height as int
139    * @param width as int
140    * @return renderdImage as BufferedImage
141    * @throws org.europa.together.exceptions.MisconfigurationException
142    */
143    @API(status = STABLE, since = "1.0")
144    BufferedImage crop(int x, int y, int height, int width)
145    throws MisconfigurationException;
146   
147    /**
148    * Flip the image horizontaly.
149    *
150    * @return renderdImage as BufferedImage
151    * @throws org.europa.together.exceptions.MisconfigurationException
152    */
153    @API(status = STABLE, since = "1.0")
154    BufferedImage flipHorizontal() throws MisconfigurationException;
155   
156    /**
157    * Flip the image verticaly.
158    *
159    * @return renderdImage as BufferedImage
160    * @throws org.europa.together.exceptions.MisconfigurationException
161    */
162    @API(status = STABLE, since = "1.0")
163    BufferedImage flipVertical() throws MisconfigurationException;
164   
165    /**
166    * Get the original loaded Image.
167    *
168    * @return image as BufferedImage
169    */
170    @API(status = STABLE, since = "1.0")
171    BufferedImage getImage();
172   
173    /**
174    * Resize an given image to a new Size. The new scale is given in percent
175    * and is be automatic calculated from the original image. The calculation
176    * is rounded, because of the mathematic operation as Integer.<br>
177    * calculation: int (original.size / 100) * percent<br>
178    *
179    * @param percentage as int
180    * @return renderdImage as BufferedImage
181    * @throws org.europa.together.exceptions.MisconfigurationException
182    */
183    @API(status = STABLE, since = "1.0")
184    BufferedImage resize(int percentage) throws MisconfigurationException;
185   
186    /**
187    * Rotate the image 90 degree steps to the right side. Clockwise rotation.
188    *
189    * @return renderdImage as BufferedImage
190    * @throws org.europa.together.exceptions.MisconfigurationException
191    */
192    @API(status = STABLE, since = "1.0")
193    BufferedImage rotateRight() throws MisconfigurationException;
194   
195    /**
196    * Get the full list of ImageMetaData.
197    *
198    * @return ImageMetaData as List
199    */
200    @API(status = STABLE, since = "2.1")
201    List<ImageMetadataItem> getMetaData();
202    }