1.源psd文件:
文字测试.zip (519.1 KB)
2.源代码:
public static void main(String[] args) throws FileNotFoundException
{
try {
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 + “文字测试.psd”;
String exportPath = dataDir + “文字测试New.png”;
PsdLoadOptions loadOptions = new PsdLoadOptions();
loadOptions.setLoadEffectsResource(true);
PngOptions options = new PngOptions();
options.setColorType(PngColorType.TruecolorWithAlpha);
long startTime = System.currentTimeMillis(); //获取开始时间
PsdImage image = (PsdImage) Image.load(sourceFileName, loadOptions);
image.save(exportPath,options);
long endTime = System.currentTimeMillis(); //获取结束时间
System.out.println("程序运行时间:" + (endTime - startTime)/1000 + "s"); //输出程序运行时间
} catch (Exception e) {
e.printStackTrace();
log.error("message:" + e.getMessage());
System.out.println("e:" + e.getMessage());
}
}
3.实际输出:
文字测试New.png (185.6 KB)
4.期望结果:
609CA48F-25D0-4FB7-B8B8-F852F2CE1C77.jpg (332.8 KB)
PS:未实现序号(2、5、6、7、8、16、17、18、19、20、21)