1.gradle 配置获取第三方jar
compile 'com.twelvemonkeys.imageio:imageio-tiff:3.4.1'
compile 'com.twelvemonkeys.imageio:imageio-jpeg:3.4.1'
compile 'com.twelvemonkeys.servlet:servlet:3.4.1'
maven配置
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-jpeg</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-tiff</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.servlet</groupId>
<artifactId>servlet</artifactId>
<version>3.4.1</version>
</dependency>
2.web.xml
<listener>
<display-name>ImageIO service provider loader/unloader</display-name>
<listener-class>com.twelvemonkeys.servlet.image.IIOProviderContextListener</listener-class>
</listener>
3.用法
tempFile 为源文件
larTempFile 为目标文件
Thumbnails.of(tempFile).size(setting.getLargeProductImageWidth(), setting.getLargeProductImageHeight()).outputQuality(1f).toFile(largeTempFile);