1.源代码:
public static void main(String[] args) throws FileNotFoundException
{
License license = new License();
String licFileDir = “E:\mysite\openproj\Aspose.PSD-for-Java\Examples\src\main\resources\Lic\Aspose.Total.Product.Family.lic”;
license.setLicense(licFileDir);
String dataDir = "E:\\mysite\\openproj\\Aspose.PSD-for-Java\\Examples\\src\\main\\resources\\PSD\\";
Cache.setCacheFolder(dataDir);
// Set cache on disk.
Cache.setCacheType(CacheType.CacheInMemoryOnly);
// The default cache max value is 0, which means that there is no upper limit
Cache.setMaxMemoryForCache(1073741824); // 1 gigabyte
// We do not recommend that you change the following property because it may greatly affect performance
Cache.setExactReallocateOnly(false);
String sourceFileName = dataDir+ "0023住宿餐饮_酒店民宿_宣传促销_活动促销_新店开业(竖).psd";
String exportPath = dataDir+ "0023住宿餐饮_酒店民宿_宣传促销_活动促销_新店开业(竖)New.png";
PsdLoadOptions loadOptions = new PsdLoadOptions();
loadOptions.setLoadEffectsResource(true);
long startTime = System.currentTimeMillis(); //获取开始时间
PsdImage image =(PsdImage) Image.load(sourceFileName,loadOptions);
PngOptions options = new PngOptions();
//options.setCompressionLevel(Compression.NONE.getValue());
options.setColorType(PngColorType.TruecolorWithAlpha);
image.save(exportPath,options);
long endTime = System.currentTimeMillis(); //获取结束时间
System.out.println("程序运行时间:" + (endTime - startTime)/1000 + "s"); //输出程序运行时间
}
2.实际输出错误信息:
“D:\Program Files\Java\jdk1.8.0_181\bin\java.exe” “-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\lib\idea_rt.jar=64388:D:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\bin” -Dfile.encoding=UTF-8 -classpath “D:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;E:\mysite\openproj\Aspose.PSD-for-Java\Examples\target\classes;D:\Users\NC0787.m2\repository\com\aspose\aspose-psd\20.9\aspose-psd-20.9.jar;D:\Users\NC0787.m2\repository\com\alibaba\simpleimage\1.2.3\simpleimage-1.2.3.jar;D:\Users\NC0787.m2\repository\commons-io\commons-io\1.2\commons-io-1.2.jar;D:\Users\NC0787.m2\repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar;D:\Users\NC0787.m2\repository\log4j\log4j\1.2.12\log4j-1.2.12.jar;D:\Users\NC0787.m2\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar;D:\Users\NC0787.m2\repository\org\slf4j\slf4j-log4j12\1.6.6\slf4j-log4j12-1.6.6.jar;D:\Users\NC0787.m2\repository\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar;D:\Users\NC0787.m2\repository\com\alibaba\fastjson\1.2.70\fastjson-1.2.70.jar;D:\Users\NC0787.m2\repository\org\projectlombok\lombok\1.18.10\lombok-1.18.10.jar;D:\Users\NC0787.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;D:\Users\NC0787.m2\repository\commons-beanutils\commons-beanutils\1.9.4\commons-beanutils-1.9.4.jar;D:\Users\NC0787.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\Users\NC0787.m2\repository\com\fasterxml\jackson\core\jackson-core\2.11.2\jackson-core-2.11.2.jar;D:\Users\NC0787.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.2\jackson-annotations-2.11.2.jar;D:\Users\NC0787.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.11.2\jackson-databind-2.11.2.jar;D:\Users\NC0787.m2\repository\org\apache\commons\commons-lang3\3.11\commons-lang3-3.11.jar;D:\Users\NC0787.m2\repository\commons-codec\commons-codec\1.14\commons-codec-1.14.jar;D:\Users\NC0787.m2\repository\org\springframework\spring-beans\5.1.5.RELEASE\spring-beans-5.1.5.RELEASE.jar;D:\Users\NC0787.m2\repository\org\springframework\spring-core\5.1.5.RELEASE\spring-core-5.1.5.RELEASE.jar;D:\Users\NC0787.m2\repository\org\springframework\spring-jcl\5.1.5.RELEASE\spring-jcl-5.1.5.RELEASE.jar;D:\Users\NC0787.m2\repository\com\esotericsoftware\kryo-shaded\3.0.3\kryo-shaded-3.0.3.jar;D:\Users\NC0787.m2\repository\com\esotericsoftware\minlog\1.3.0\minlog-1.3.0.jar;D:\Users\NC0787.m2\repository\org\objenesis\objenesis\2.1\objenesis-2.1.jar;D:\Users\NC0787.m2\repository\com\dyuproject\protostuff\protostuff-core\1.1.3\protostuff-core-1.1.3.jar;D:\Users\NC0787.m2\repository\com\dyuproject\protostuff\protostuff-api\1.1.3\protostuff-api-1.1.3.jar;D:\Users\NC0787.m2\repository\com\dyuproject\protostuff\protostuff-runtime\1.1.3\protostuff-runtime-1.1.3.jar;D:\Users\NC0787.m2\repository\com\dyuproject\protostuff\protostuff-collectionschema\1.1.3\protostuff-collectionschema-1.1.3.jar” com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.NvWangPsdParseCopy
Trying to install font family DengXian at C:\WINDOWS\Fonts\Deng.ttf to private collection
Font family DengXian with style Regular is not available: please, try to reinstall this font
Trying to install font family DengXian at C:\WINDOWS\Fonts\Dengb.ttf to private collection
Font family DengXian with style Bold is not available: please, try to reinstall this font
Trying to install font family DengXian Light at C:\WINDOWS\Fonts\Dengl.ttf to private collection
Font family DengXian Light with style Regular is not available: please, try to reinstall this font
Trying to install font family Gill Sans Nova Cond Ultra Bold at C:\WINDOWS\Fonts\GillSansCondUltraBoNova.ttf to private collection
Font family Gill Sans Nova Cond Ultra Bold with style Regular is not available: please, try to reinstall this font
Trying to install font family Gill Sans Nova Ultra Bold at C:\WINDOWS\Fonts\GillSansUltraBoNova.ttf to private collection
Font family Gill Sans Nova Ultra Bold with style Regular is not available: please, try to reinstall this font
Trying to install font family Microsoft YaHei at C:\WINDOWS\Fonts\msyh.ttc to private collection
Font family Microsoft YaHei with style Regular is not available: please, try to reinstall this font
Trying to install font family Microsoft YaHei at C:\WINDOWS\Fonts\msyhbd.ttc to private collection
Font family Microsoft YaHei with style Bold is not available: please, try to reinstall this font
Trying to install font family Microsoft YaHei Light at C:\WINDOWS\Fonts\msyhl.ttc to private collection
Font family Microsoft YaHei Light with style Regular is not available: please, try to reinstall this font
Trying to install font family Neue Haas Grotesk Text Pro Medium at C:\WINDOWS\Fonts\NHaasGroteskTXPro-65Md.ttf to private collection
Font family Neue Haas Grotesk Text Pro Medium with style Regular was succesfully installed to private collection
Trying to install font family Neue Haas Grotesk Text Pro Medium at C:\WINDOWS\Fonts\NHaasGroteskTXPro-66MdIt.ttf to private collection
Font family Neue Haas Grotesk Text Pro Medium with style Italic was succesfully installed to private collection
Trying to install font family Rockwell Nova Extra Bold at C:\WINDOWS\Fonts\RockwellNova-ExtraBold.ttf to private collection
Font family Rockwell Nova Extra Bold with style Regular is not available: please, try to reinstall this font
Trying to install font family Rockwell Nova Extra Bold at C:\WINDOWS\Fonts\RockwellNova-ExtraBoldItalic.ttf to private collection
Font family Rockwell Nova Extra Bold with style Italic is not available: please, try to reinstall this font
Trying to install font family FangSong at C:\WINDOWS\Fonts\simfang.ttf to private collection
Font family FangSong with style Regular is not available: please, try to reinstall this font
Trying to install font family SimHei at C:\WINDOWS\Fonts\simhei.ttf to private collection
Font family SimHei with style Regular is not available: please, try to reinstall this font
Trying to install font family KaiTi at C:\WINDOWS\Fonts\simkai.ttf to private collection
Font family KaiTi with style Regular is not available: please, try to reinstall this font
Trying to install font family SimSun at C:\WINDOWS\Fonts\simsun.ttc to private collection
Font family SimSun with style Regular is not available: please, try to reinstall this font
Trying to install font family NSimSun at C:\WINDOWS\Fonts\simsun.ttc to private collection
Font family NSimSun with style Regular is not available: please, try to reinstall this font
Trying to install font family Verdana Pro Light at C:\WINDOWS\Fonts\VerdanaPro-Light.ttf to private collection
Font family Verdana Pro Light with style Regular was succesfully installed to private collection
Trying to install font family Yu Gothic UI Semibold at C:\WINDOWS\Fonts\YuGothB.ttc to private collection
Font family Yu Gothic UI Semibold with style Regular is not available: please, try to reinstall this font
Font cache was not available for : AlibabaPuHuiTiR
Font cache was not available for : YouSheBiaoTiHei
Font cache was not available for : YouSheBiaoTiHei
Exception in thread “main” class com.aspose.psd.coreexceptions.ImageSaveException: Image saving failed. —> class com.aspose.psd.coreexceptions.ImageSaveException: Image export failed. —> java.lang.ArrayIndexOutOfBoundsException: 2073756
— End of inner exception stack trace —
com.aspose.psd.Image.a(Unknown Source)
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.NvWangPsdParseCopy.main(NvWangPsdParseCopy.java:51)
— End of inner exception stack trace —
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.NvWangPsdParseCopy.main(NvWangPsdParseCopy.java:51)
at com.aspose.psd.Image.save(Unknown Source)
at com.aspose.psd.Image.save(Unknown Source)
at com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.NvWangPsdParseCopy.main(NvWangPsdParseCopy.java:51)
Caused by: class com.aspose.psd.coreexceptions.ImageSaveException: Image export failed. —> java.lang.ArrayIndexOutOfBoundsException: 2073756
— End of inner exception stack trace —
com.aspose.psd.Image.a(Unknown Source)
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.Image.save(Unknown Source)
com.aspose.psd.examples.ModifyingAndConvertingImages.PSD.NvWangPsdParseCopy.main(NvWangPsdParseCopy.java:51)
at com.aspose.psd.Image.a(Unknown Source)
… 3 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2073756
at com.aspose.psd.internal.hK.d.a(Unknown Source)
at com.aspose.psd.internal.hO.e$a.a(Unknown Source)
at com.aspose.psd.internal.hO.e$a.process(Unknown Source)
at com.aspose.psd.internal.hS.G.a(Unknown Source)
at com.aspose.psd.internal.hS.G.process(Unknown Source)
at com.aspose.psd.internal.hS.m.process(Unknown Source)
at com.aspose.psd.internal.hK.b.loadPartialArgb32Pixels(Unknown Source)
at com.aspose.psd.internal.fQ.ap.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.hP.d.b(Unknown Source)
at com.aspose.psd.internal.hP.d.a(Unknown Source)
at com.aspose.psd.internal.hO.e$d.a(Unknown Source)
at com.aspose.psd.internal.hO.e$d.process(Unknown Source)
at com.aspose.psd.internal.hO.e$c.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.hO.e$b.loadPartialArgb32Pixels(Unknown Source)
at com.aspose.psd.internal.fQ.ap.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.ar.a(Unknown Source)
at com.aspose.psd.internal.fQ.aa.a(Unknown Source)
at com.aspose.psd.RasterImage.a(Unknown Source)
at com.aspose.psd.RasterImage.loadPartialArgb32Pixels(Unknown Source)
at com.aspose.psd.internal.hI.e.a(Unknown Source)
at com.aspose.psd.internal.hI.e.a(Unknown Source)
at com.aspose.psd.internal.hD.b.a(Unknown Source)
… 4 more
Process finished with exit code 1