ImageIO解析TIF转为JPEG Posted on 2019-04-23 12345static{IIORegistry registry = IIORegistry.getDefaultInstance();registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriterspi());registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderspi();} 另一种方式,META-INF/service下已经有了服务注册的信息,没有注册上是由于maven打包的时候使用覆盖的方式,有重名的文件会覆盖。使用maven插件可以避免此问题。 123456789101112131415161718192021<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/services/javax.imageio.spi.ImageReaderSpi</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin>