ImageIO 支持更多的图片格式

编程入门 行业动态 更新时间:2024-10-07 12:28:52

ImageIO 支持更多的<a href=https://www.elefans.com/category/jswz/34/1752044.html style=图片格式"/>

ImageIO 支持更多的图片格式

TwelveMonkeys 提供了更多的图片格式用于图片的读写;根据 TwelveMonkeys 提供的文档,其目前支持的图片格式如下:

PluginFormatDescriptionRWMetadataNotes
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-
HDRHDRRadiance High Dynamic Range RGBE Format-Standard
ICNSICNSApple Icon Image-
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 Image FormatStandard
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

此表格来源于github:

GitHub - haraldk/TwelveMonkeys: TwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIOTwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIO - GitHub - haraldk/TwelveMonkeys: TwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIO TwelveMonkeys 所有支持的图片格式,其中JDK中已经原生支持 BMP,  JPEG, JPG, GIF, WBMP, PNG等图片格式;除了JDK提供的图片格式,我们经常使用到的图片格式还有 SVG, PSD, TIFF, WebP;下面我们在原来的JDK提供的图片格式上增加对这几种图片格式的扩展。

引入依赖:

<!-- svg格式插件,需要添加batik依赖 -->
<dependency><groupId>com.twelvemonkeys.imageio</groupId><artifactId>imageio-batik</artifactId><version>3.9.4</version>
</dependency>
<dependency><groupId>org.apache.xmlgraphics</groupId><artifactId>batik-all</artifactId><version>1.16</version>
</dependency>
<!-- psd格式插件 -->
<dependency><groupId>com.twelvemonkeys.imageio</groupId><artifactId>imageio-psd</artifactId><version>3.9.4</version>
</dependency>
<!-- tiff格式插件 -->
<dependency><groupId>com.twelvemonkeys.imageio</groupId><artifactId>imageio-tiff</artifactId><version>3.9.4</version>
</dependency>
<!-- webp格式插件 -->
<dependency><groupId>com.twelvemonkeys.imageio</groupId><artifactId>imageio-webp</artifactId><version>3.9.4</version>
</dependency>

下面获取ImageIO支持的图片格式:

String[] readerFormatNames = ImageIO.getReaderFormatNames();
System.out.println("reader: " + Arrays.asList(readerFormatNames));
String[] writerFormatNames = ImageIO.getWriterFormatNames();
System.out.println("writer: " + Arrays.asList(writerFormatNames));

执行的结果如下:

reader: [psd, JPG, tiff, bigtiff, bmp, wbp, gif, SVG, WBMP, PNG, JPEG, BigTIFF, tif, wmf, TIFF, wbmp, jpeg, PSB, PSD, jpg, BMP, WBP, GIF, svg, png, BIGTIFF, webp, TIF, WMF, WEBP, psb]
writer: [psd, PSD, JPG, jpg, tiff, bigtiff, bmp, BMP, gif, GIF, WBMP, png, PNG, BIGTIFF, JPEG, BigTIFF, tif, TIF, TIFF, wbmp, jpeg, psb, PSB]

从上面的打印结果来看,已经支持了SVG, PSD, TIFF, WEBP格式的读取,但仅支持PSD, TIFF格式的写出,不支持SVG, WEBP格式的写出。 

更多推荐

ImageIO 支持更多的图片格式

本文发布于:2024-02-13 22:07:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1761051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图片格式   更多   ImageIO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!