Java BufferedImage Compress compressPhoto(Image originImg, int newWidth, int newHeight)

Here you can find the source of compressPhoto(Image originImg, int newWidth, int newHeight)

Description

compress Photo

License

Open Source License

Declaration

public static Image compressPhoto(Image originImg, int newWidth, int newHeight) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Image;
import java.awt.image.BufferedImage;

public class Main {

    public static Image compressPhoto(Image originImg, int newWidth, int newHeight) {
        Image newImg = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);
        newImg.getGraphics().drawImage(originImg.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH), 0, 0,
                null);/*from w  ww  . ja  v  a 2 s  . com*/
        return newImg;
    }
}

Related

  1. compress(BufferedImage image, float quality)
  2. compress(BufferedImage image, String path)
  3. compressImage(BufferedImage originalImage, int type, int width, int height)
  4. compression(BufferedImage src, int scale)