-1

我发现 commons 成像库最适合我的需求,但是缺少该库使用的示例。有没有人有一个例子如何无损旋转jpeg图像(即仅通过更改文件元数据)?谢谢!

4

2 回答 2

0

有一个类 RotatedIcon(见链接)可以像这样使用

        if (imageOrientation.equals("3")) {
          rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.UPSIDE_DOWN);
        } else if (imageOrientation.equals("6")) {
          rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.DOWN);
        } else if (imageOrientation.equals("8")) {
          rotatedIcon = new RotatedIcon(imageIcon, RotatedIcon.Rotate.UP);
        }

imageOrientation 是图像元数据的属性(例如 EXIF)

https://tips4java.wordpress.com/2009/04/06/rotated-icon/

https://github.com/griffon/griffon-javatips-plugin/blob/master/src/main/com/wordpress/tipsforjava/swing/RotatedIcon.java

于 2015-02-08T17:54:18.283 回答
0

请参阅此问题的答案,了解如何使用 Commons Imaging 库添加/删除元数据。您要设置的标签是org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants#TIFF_TAG_ORIENTATION.

于 2022-02-09T10:44:55.183 回答