我正在尝试将图像调整为缩略图。但是,当我调整垂直图像的大小时,它会变成水平位置。如何保持图像方向?
试过 IIOMetadata = metadate.getImageMetadata(0);
public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) 抛出异常 { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Thumbnails.of(原始图像) .size(targetWidth, targetHeight) .outputFormat("JPEG") .输出质量(1) .useExifOrientation(真) .toOutputStream(outputStream); byte[] data = outputStream.toByteArray(); ByteArrayInputStream inputStream = new ByteArrayInputStream(数据); 返回 ImageIO.read(inputStream); }