Rescale JPG : JPEG « 2D Graphics « Java Tutorial






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

import javax.imageio.ImageIO;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedImage bsrc = ImageIO.read(new File("a.jpg"));
    BufferedImage bdest = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = bdest.createGraphics();
    AffineTransform at = AffineTransform.getScaleInstance(2, 2);
    g.drawRenderedImage(bsrc, at);
    ImageIO.write(bdest, "JPG", new File("b.jpg"));
  }
}








16.29.JPEG
16.29.1.Encoding an image to a JPEG file
16.29.2.Rescale JPG