Rescale JPG : JPEG « 2D Graphics GUI « Java

Rescale JPG


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

import javax.imageio.ImageIO;

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


Related examples in the same category

1.Encoding an image to a JPEG file
2.Get Jpeg Properties
3.Takes a list of JPEG image files and convert them into a QuickTime movie.
4.Performs a jpeg compression of an image
5.Returns all jpg images from a directory in an array
6.Writes an image to an output stream as a JPEG file. The JPEG quality can be specified in percent.