Java BufferedImage Thumbnail thumbnail(int imageWidth, int imageHeight, File originFileName, File thumbFileName)

Here you can find the source of thumbnail(int imageWidth, int imageHeight, File originFileName, File thumbFileName)

Description

thumbnail

License

Open Source License

Declaration

public static boolean thumbnail(int imageWidth, int imageHeight, File originFileName, File thumbFileName) 

Method Source Code

//package com.java2s;
/**********************************
 keywe spooncms version [1.0]/*from   w w  w  .  ja v  a  2 s .com*/
    
 Copyright ? 2015 keywesoft Inc. All rights reserved.
    
 This is a proprietary software of kt Inc. and you may not use this file except in
 compliance with license agreement with kt Inc. Any redistribution or use of this
 software, with or without modification shall be strictly prohibited without prior
 written approval of kt Inc. and the copyright notice above does not evidence any
 actual or intended publication of such software.
 *********************************/

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class Main {
    public static boolean thumbnail(int imageWidth, int imageHeight, File originFileName, File thumbFileName) {
        boolean result = false;
        try {
            BufferedImage bufferOriginImg = ImageIO.read(originFileName);
            BufferedImage bufferThumbImg = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_3BYTE_BGR);
            Graphics2D graphic = bufferThumbImg.createGraphics();
            graphic.drawImage(bufferOriginImg, 0, 0, imageWidth, imageHeight, null);
            ImageIO.write(bufferThumbImg, "jpg", thumbFileName);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }
}

Related

  1. thumbnail(File input, File output, int sizeX, int sizeY)
  2. thumbnail(final InputStream inputStream, final int width, final int height, final OutputStream outputStream)