一般Java通过javax.imageio.ImageIO操作jpeg与png没有问题,但是操作tiff时就会报错,此时只要引入如下的包即可,不需要修改代码即可兼容tiff
<dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-core</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-metadata</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-tiff</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-tiff-jai-interop</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-tiff-jdk-interop</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-jpeg</artifactId> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-bmp</artifactId> </dependency>
------------
// 读取jpeg、png、tiff、bmp BufferedImage bufferedImage = javax.imageio.ImageIO.read(new File(filePath));标签:Java,TIFF,tiff,jpeg,twelvemonkeys,操作,imageio,com From: https://www.cnblogs.com/gispathfinder/p/17383823.html