1.源文件:
009住宿餐饮-餐饮甜品-宣传促销-节日促销-七夕节 竖版.zip (5.0 MB)
2.源代码:
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+ "009住宿餐饮-餐饮甜品-宣传促销-节日促销-七夕节 竖版.psd";
String exportPath = dataDir+ "009住宿餐饮-餐饮甜品-宣传促销-节日促销-七夕节 竖版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(); //获取结束时间
//image.dispose();
System.out.println("程序运行时间:" + (endTime - startTime)/1000 + "s"); //输出程序运行时间
}
3.实际输出:
image.png (77.5 KB)
4.预期输出:执行OK