javax.imageio.IIOException: Unsupported Image Type
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1079)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1050)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
at javax.imageio.ImageIO.read(ImageIO.java:1352)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
-------------------------------
ImageIO.read() 无法处理ps过后的图片
P过的图片保存为jpg格式时,默认的模式是CMYK模式
只能读取png模式
解决方案
使用插件
https://github.com/haraldk/TwelveMonkeys
mvn管理
<!--图片处理 start --> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-jpeg</artifactId> <version>3.6</version> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-tiff</artifactId> <version>3.6</version> </dependency> <!-- Optional dependency. Needed only if you deploy `ImageIO` plugins as part of a web app. Make sure you add the `IIOProviderContextListener` to your `web.xml`, see above. --> <dependency> <groupId>com.twelvemonkeys.servlet</groupId> <artifactId>servlet</artifactId> <version>3.6</version> </dependency> <!--图片处理 end -->