1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.image

File ImageProcessor.java

 

Code metrics

0
0
0
1
76
15
0
-
-
0
-

Classes

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

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.plugin.image;
21   
22    import java.awt.Image;
23    import java.awt.image.RenderedImage;
24    import java.io.IOException;
25    import java.io.InputStream;
26    import java.io.OutputStream;
27   
28    import org.xwiki.component.annotation.Role;
29   
30    /**
31    * Component used to process images.
32    *
33    * @version $Id: fe12747c0b679f24c976ac1fdb75ff5f7c1bc3c8 $
34    * @since 2.5M2
35    */
36    @Role
 
37    public interface ImageProcessor
38    {
39    /**
40    * Reads an image from an input stream.
41    *
42    * @param inputStream the input stream to read the image from
43    * @return the read image
44    * @throws IOException if reading the image fails
45    */
46    Image readImage(InputStream inputStream) throws IOException;
47   
48    /**
49    * Encodes the given image to match the specified mime type, if possible, and writes it to the output stream, using
50    * the specified compression quality if appropriate.
51    *
52    * @param image the image to be written to the output stream
53    * @param mimeType the image mime type (e.g. (e.g. "image/jpeg" or "image/png")
54    * @param quality the compression quality; use this parameter to reduce the size, i.e. the number of bytes, of the
55    * image
56    * @param out the output stream to write the image to
57    * @throws IOException if writing the image fails
58    */
59    void writeImage(RenderedImage image, String mimeType, float quality, OutputStream out) throws IOException;
60   
61    /**
62    * Scales the given image to the specified dimensions.
63    *
64    * @param image the image to be scaled
65    * @param width the new image width
66    * @param height the new image height
67    * @return the scaled image
68    */
69    RenderedImage scaleImage(Image image, int width, int height);
70   
71    /**
72    * @param mimeType the mime type to be checked
73    * @return {@code true} if the given mime type is supported, {@code false} otherwise
74    */
75    boolean isMimeTypeSupported(String mimeType);
76    }