1.源psd文件:
满减.zip (27.2 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 (19.8 KB)
4.期望结果:
满减expect.png (20.6 KB)