1.在idea中使用如下代碼將CGM裝換其他格式圖片時正常執行,當將項目打成jar執行時ImageIO.write(image, "PNG", tarFile);報空指針異常。
File tarFile = new File(filePath + ".png");
BufferedImage image = ImageIO.read(f);
ImageIO.write(image, "PNG", tarFile);
2.原因是:在命令提示符下只支持12種圖像格式,但是在idea中支持24中圖像格式,加入jai_imageio.jar包放置在maven的pom中,項目打成的jar包也就開始支持24中圖像格式了。
jai_imageio.jar的下載地址如下:
鏈接:https://pan.baidu.com/s/1YgI37yuYeNOldzthZD6X_w 提取碼:5jcq 複製這段內容後打開百度網盤手機App,操作更方便哦