java图片处理-twelvemonkeys

java图片处理 - TwelveMonkeys ImageIO

javax.imageio原生支持的格式很少,特殊格式使用 ImageIO.read 获取的为null

可以用getWriterFileSuffixes()查询支持格式

String[] writerFileSuffixes = ImageIO.getWriterFileSuffixes();

原生支持格式

jpg,bmp,gif,png,jpeg,wbmp

TwelveMonkeys ImageIO 是对于 javax.imageio.*包 扩展的插件,这个插件配置后可以添加JRE本身没有覆盖的格式

中文翻译地址

文件格式支持列表

表格来自 TwelveMonkeys 文档

插件格式简介元数据文档
BatikSVGScalable Vector Graphics--Requires Batik
WMFMS Windows Metafile--Requires Batik
BMPBMPMS Windows and IBM OS/2 Device Independent BitmapNative, Standard
CURMS Windows Cursor Format--
ICOMS Windows Icon Format-
HDRHDR辐射高动态范围RGBE格式-Standard
ICNSICNS苹果图标图像-
IFFIFFCommodore Amiga/Electronic Arts Interchange File FormatStandard
JPEGJPEGJoint Photographers Expert GroupNative, Standard
JPEG Lossless-Native, Standard
PCXPCXZSoft Paintbrush Format-Standard
DCXMulti-page PCX fax document-Standard
PICTPICTApple QuickTime Picture FormatStandard
PNTGApple MacPaint Picture Format-Standard
PNMPAMNetPBM Portable Any MapStandard
PBMNetPBM Portable Bit Map-Standard
PGMNetPBM Portable Grey Map-Standard
PPMNetPBM Portable Pix MapStandard
PFMPortable Float Map-Standard
PSDPSDAdobe Photoshop Document(✔)Native, Standard
PSBAdobe Photoshop Large Document-Native, Standard
SGISGISilicon Graphics Image Format-Standard
TGATGATruevision TGA图像格式Standard
ThumbsDBThumbs.dbMS Windows Thumbs DB--OLE2 Compound Document based format only
TIFFTIFFAldus/Adobe Tagged Image File FormatNative, Standard
BigTIFFNative, Standard
WebPWebPGoogle WebP Format-Standard
XWDXWDX11 Window Dump Format-Standard

引入该插件后支持的格式

jpg,tpic,tiff,bmp,gif,tf8,png,btiff,tga,tif,btf,jpeg,wbmp

maven依赖

 <dependency>
            <groupId>com.twelvemonkeys.imageio</groupId>
            <artifactId>imageio-jpeg</artifactId>
            <version>3.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.twelvemonkeys.imageio</groupId>
            <artifactId>imageio-tiff</artifactId>
            <version>3.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.twelvemonkeys.servlet</groupId>
            <artifactId>servlet</artifactId>
            <version>3.9.4</version>
        </dependency>
        <dependency>
            <groupId>com.twelvemonkeys.servlet</groupId>
            <artifactId>servlet</artifactId>
            <version>3.9.4</version>
            <classifier>jakarta</classifier>
        </dependency>

tga图片等特殊格式需要额外添加本地依赖

<dependency>
            <groupId>javax.imageio</groupId>
            <artifactId>tga</artifactId>
            <version>3.9.4</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/jar/imageio-tga-3.9.4.jar</systemPath>
        </dependency>

tga图片转jpg

try {
            BufferedImage bufferegImage = ImageIO.read(new File("E:\\input.tga"));
            ImageIO.write(bufferegImage, "png", new File("E:output.jpg"));
        }catch (Exception e){
            System.out.println(e.getMessage());
        }

ImageIO插件

可以通过添加插件,增加imageio支持的文件格式

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值