001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.model.Image;
020    
021    import java.awt.image.BufferedImage;
022    import java.awt.image.RenderedImage;
023    
024    import java.io.File;
025    import java.io.IOException;
026    import java.io.InputStream;
027    import java.io.OutputStream;
028    
029    import java.util.concurrent.Future;
030    
031    /**
032     * @author Brian Wing Shun Chan
033     * @author Alexander Chow
034     */
035    @ProviderType
036    public interface ImageTool {
037    
038            public static final String TYPE_BMP = "bmp";
039    
040            public static final String TYPE_GIF = "gif";
041    
042            public static final String TYPE_JPEG = "jpg";
043    
044            public static final String TYPE_NOT_AVAILABLE = "na";
045    
046            public static final String TYPE_PNG = "png";
047    
048            public static final String TYPE_TIFF = "tiff";
049    
050            public Future<RenderedImage> convertCMYKtoRGB(byte[] bytes, String type);
051    
052            public BufferedImage convertImageType(BufferedImage sourceImage, int type);
053    
054            public RenderedImage crop(
055                    RenderedImage renderedImage, int height, int width, int x, int y);
056    
057            public void encodeGIF(RenderedImage renderedImage, OutputStream os)
058                    throws IOException;
059    
060            public void encodeWBMP(RenderedImage renderedImage, OutputStream os)
061                    throws IOException;
062    
063            public BufferedImage getBufferedImage(RenderedImage renderedImage);
064    
065            public byte[] getBytes(RenderedImage renderedImage, String contentType)
066                    throws IOException;
067    
068            public Image getDefaultCompanyLogo();
069    
070            public Image getDefaultOrganizationLogo();
071    
072            public Image getDefaultSpacer();
073    
074            public Image getDefaultUserFemalePortrait();
075    
076            public Image getDefaultUserMalePortrait();
077    
078            public Image getImage(byte[] bytes) throws IOException;
079    
080            public Image getImage(File file) throws IOException;
081    
082            public Image getImage(InputStream is) throws IOException;
083    
084            public Image getImage(InputStream is, boolean cleanUpStream)
085                    throws IOException;
086    
087            public boolean isNullOrDefaultSpacer(byte[] bytes);
088    
089            public ImageBag read(byte[] bytes) throws IOException;
090    
091            public ImageBag read(File file) throws IOException;
092    
093            public ImageBag read(InputStream inputStream) throws IOException;
094    
095            public RenderedImage scale(RenderedImage renderedImage, int width);
096    
097            public RenderedImage scale(
098                    RenderedImage renderedImage, int maxHeight, int maxWidth);
099    
100            public abstract void write(
101                            RenderedImage renderedImage, String contentType, OutputStream os)
102                    throws IOException;
103    
104    }