图片压缩时 某个 jpeg图片 报错 Unsupported Image Type
2016-03-01 15:51
489 查看
ImageIO.read 读取某个图片的时候报错 Unsupported Image Type。
其他的同类型图片没问题。查询发现是这样的:默认的模式是CMYK模式(注意,这是给印刷机用的)。在图像-->模式中改为RGB模式才是显示器用的
对应的网站:http://stackoverflow.com/questions/2408613/unable-to-read-jpeg-image-using-imageio-readfile-file
最好的解决方案如下,采用 twelvemonkeys 的相关组件。代码不用任何修改
使用方法。
maven中加上对应的dependency,
web.xml中加上
<listener>
<display-name>ImageIO service provider loader/unloader</display-name>
<listener-class>com.twelvemonkeys.servlet.image.IIOProviderContextListener</listener-class>
</listener>
Old post, but for future reference:
Inspired by this question and links found here, I've written a JPEGImageReader plugin for ImageIO that supports CMYK color models (both with original color model, or implicitly converted to RGB on read). The reader also does proper color conversion, using the
ICC profile embedded in the JPEG stream, in contrast to other solutions mentioned here.
It's plain Java and does not require JAI. The source code and binary distributions is freely available atgithub.com/haraldk/TwelveMonkeys.
Once you have it installed, it allows you to read CMYK JPEGs using
this:
I.e.: In most cases, it's not necessary to modify your code.
参考其他网站:http://blog.csdn.net/shixing_11/article/details/6897871
http://www.doc88.com/p-58261301281.html http://www.oschina.net/p/evathumber/similar_projects?lang=19&sort=time&p=1
其他的同类型图片没问题。查询发现是这样的:默认的模式是CMYK模式(注意,这是给印刷机用的)。在图像-->模式中改为RGB模式才是显示器用的
对应的网站:http://stackoverflow.com/questions/2408613/unable-to-read-jpeg-image-using-imageio-readfile-file
最好的解决方案如下,采用 twelvemonkeys 的相关组件。代码不用任何修改
使用方法。
maven中加上对应的dependency,
web.xml中加上
<listener>
<display-name>ImageIO service provider loader/unloader</display-name>
<listener-class>com.twelvemonkeys.servlet.image.IIOProviderContextListener</listener-class>
</listener>
Old post, but for future reference:
Inspired by this question and links found here, I've written a JPEGImageReader plugin for ImageIO that supports CMYK color models (both with original color model, or implicitly converted to RGB on read). The reader also does proper color conversion, using the
ICC profile embedded in the JPEG stream, in contrast to other solutions mentioned here.
It's plain Java and does not require JAI. The source code and binary distributions is freely available atgithub.com/haraldk/TwelveMonkeys.
Once you have it installed, it allows you to read CMYK JPEGs using
ImageIO.read(...)like
this:
File cmykJPEGFile = new File(/*path*/); BufferedImage image = ImageIO.read(cmykJPEGFile);
I.e.: In most cases, it's not necessary to modify your code.
参考其他网站:http://blog.csdn.net/shixing_11/article/details/6897871
http://www.doc88.com/p-58261301281.html http://www.oschina.net/p/evathumber/similar_projects?lang=19&sort=time&p=1
相关文章推荐
- HDOJ 1715 大菲波数
- unity 切圆角矩形 --shader编程
- jsonp使用,spring4.x对jsonp的支持
- Atitit.linq java的原理与实现 解释器模式
- Atitit.linq java的原理与实现 解释器模式
- HDOJ 1715 大菲波数
- LAMP中php配置
- 【最大流/费用流】BZOJ1834-[ZJOI2010]network 网络扩容
- SPRING IN ACTION 第4版笔记-第二章-002-@ComponentScan、@Autowired的用法
- 说下查询动作 Pivot
- iOS 新手指引在App中的添加,第一次启动应用程序出现,后面都不出现
- Android Paint和Color类学习
- Nginx简单配置
- Atitit.wrmi web rmi框架新特性
- js判断是移动端还是pc端
- C#中字符串前面加@的作用
- python引用非当前作用于变量时需使用关键字声明一下
- 【Linux运维-集群技术进阶】集群/分布式环境下5种session处理策略
- UITapGestureRecognizer点击手势区分单双击
- Atitit.wrmi web rmi框架新特性