001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.image;
016    
017    import com.liferay.portal.model.Image;
018    
019    import java.awt.image.BufferedImage;
020    import java.awt.image.RenderedImage;
021    
022    import java.io.File;
023    import java.io.IOException;
024    import java.io.InputStream;
025    import java.io.OutputStream;
026    
027    import java.util.concurrent.Future;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     * @author Alexander Chow
032     */
033    public interface ImageTool {
034    
035            public static final String TYPE_BMP = "bmp";
036    
037            public static final String TYPE_GIF = "gif";
038    
039            public static final String TYPE_JPEG = "jpg";
040    
041            public static final String TYPE_NOT_AVAILABLE = "na";
042    
043            public static final String TYPE_PNG = "png";
044    
045            public static final String TYPE_TIFF = "tiff";
046    
047            public Future<RenderedImage> convertCMYKtoRGB(byte[] bytes, String type);
048    
049            public BufferedImage convertImageType(BufferedImage sourceImage, int type);
050    
051            public void encodeGIF(RenderedImage renderedImage, OutputStream os)
052                    throws IOException;
053    
054            public void encodeWBMP(RenderedImage renderedImage, OutputStream os)
055                    throws IOException;
056    
057            public BufferedImage getBufferedImage(RenderedImage renderedImage);
058    
059            public byte[] getBytes(RenderedImage renderedImage, String contentType)
060                    throws IOException;
061    
062            public Image getDefaultCompanyLogo();
063    
064            public Image getDefaultOrganizationLogo();
065    
066            public Image getDefaultSpacer();
067    
068            public Image getDefaultUserFemalePortrait();
069    
070            public Image getDefaultUserMalePortrait();
071    
072            public Image getImage(byte[] bytes)
073                    throws IOException;
074    
075            public Image getImage(File file) throws IOException;
076    
077            public Image getImage(InputStream is) throws IOException;
078    
079            public Image getImage(InputStream is, boolean cleanUpStream)
080                    throws IOException;
081    
082            public boolean isNullOrDefaultSpacer(byte[] bytes);
083    
084            public ImageBag read(byte[] bytes) throws IOException;
085    
086            public ImageBag read(File file) throws IOException;
087    
088            public ImageBag read(InputStream inputStream) throws IOException;
089    
090            public RenderedImage scale(RenderedImage renderedImage, int width);
091    
092            public RenderedImage scale(
093                    RenderedImage renderedImage, int maxHeight, int maxWidth);
094    
095            public abstract void write(
096                            RenderedImage renderedImage, String contentType, OutputStream os)
097                    throws IOException;
098    
099    }