Here you can find the source of rotateClockwise(Path source, Path target)
public static void rotateClockwise(Path source, Path target) throws IOException
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; import java.io.IOException; import java.nio.file.Path; import javax.imageio.ImageIO; public class Main { public static void rotateClockwise(Path source, Path target) throws IOException { BufferedImage srcImage = ImageIO.read(source.toFile()); // AffineTransform affineTransform = AffineTransform.getRotateInstance(Math.toRadians(90), srcImage.getWidth() / 2, srcImage.getHeight() / 2); // BufferedImage targetImage = new BufferedImage(srcImage.getHeight(), srcImage.getWidth(), srcImage.getType()); // Graphics2D g = (Graphics2D) targetImage.getGraphics(); // g.setTransform(affineTransform); // g.drawImage(srcImage, 0, 0, null); int width = srcImage.getWidth(); int height = srcImage.getHeight(); BufferedImage targetImage = new BufferedImage(height, width, srcImage.getType()); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { targetImage.setRGB(y, (width - x - 1), srcImage.getRGB(x, y)); }//from w w w . j a v a2 s. c om } ImageIO.write(targetImage, "jpeg", target.toFile()); } }