Aspose.PSD for Python via .NET 24.2 - 发行说明
Contents
[
Hide
]
本页包含 Aspose.PSD for Python via .NET 24.2 的发行说明
关键 | 摘要 | 类别 |
---|---|---|
PSDPYTHON-28 | 处理 PatternFillSettings 的 Angle 属性 | 功能 |
PSDPYTHON-29 | 支持 TextLayer 的垂直和水平缩放 | 功能 |
PSDPYTHON-33 | [AI 格式] 实现 PDF-Based AI 格式中背景的正确渲染 | 功能 |
PSDPYTHON-34 | 更改 warp 中的 Distort 机制 | 增强 |
PSDPYTHON-35 | 加快 warp 的速度 | 增强 |
PSDPYTHON-36 | 在打开文档时出现“图像加载失败”异常 | 缺陷 |
PSDPYTHON-37 | 修复保存具有 Stroke Pattern 的 psd 文件 | 缺陷 |
PSDPYTHON-38 | 当使用 ReplaceContents 时,智能对象中的文本样式不正确 | 缺陷 |
PSDPYTHON-39 | [AI 格式] 修复 AI 文件中的 Cubic Bezier 渲染 | 缺陷 |
公共 API 更改
已添加的 API:
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Angle
已移除的 API:
- 无
用法示例:
PSDPYTHON-28. 处理 PatternFillSettings 的 Angle 属性
文件名 = "PatternFillLayerWide_0"
sourceFile = fileName + ".psd"
outputFile = fileName + "_output.psd"
loadOpt = PsdLoadOptions()
loadOpt.load_effects_resource = True
with PsdImage.load(sourceFile, loadOpt) as img:
image = cast(PsdImage, img)
fillLayer = cast(FillLayer, image.layers[1])
fillSettings = fillLayer.fill_settings
fillSettings.angle = 70
fillLayer.update()
image.save(outputFile, PsdOptions())
with PsdImage.load(outputFile, loadOpt) as img:
image = cast(PsdImage, img)
fillLayer = cast(FillLayer, image.layers[1])
fillSettings = fillLayer.fill_settings
assert fillSettings.angle == 70
PSDPYTHON-29. 支持 TextLayer 的垂直和水平缩放
sourceFile = "1719_src.psd"
outputFile = "output.png"
# 添加几种字体
fontsFolder = "1719_Fonts"
fontFolders = list(FontSettings.get_fonts_folders())
fontFolders.append(fontsFolder)
FontSettings.set_fonts_folders(fontFolders, True)
with PsdImage.load(sourceFile) as image:
image.save(outputFile, PngOptions())
PSDPYTHON-33. [AI 格式] 实现 PDF-Based AI 格式中背景的正确渲染
sourceFile = "pineapples.ai"
outputFile = "pineapples.png"
with AiImage.load(sourceFile) as image:
image.save(outputFile, PngOptions())
PSDPYTHON-34. 更改 warp 中的 Distort 机制
sourceFile = "crow_grid.psd"
outputFile = self.GetFileInOutputFolder("export.png")
opt = PsdLoadOptions()
opt.load_effects_resource = True
opt.allow_warp_repaint = True
pngOpt = PngOptions()
pngOpt.compression_level = 9
pngOpt.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
with PsdImage.load(sourceFile, opt) as img:
img.save(outputFile, pngOpt)
PSDPYTHON-35. 加快 warp 的速度
sourceFile = "output.psd"
outputFile = "export.png"
opt = PsdLoadOptions()
opt.load_effects_resource = True
opt.allow_warp_repaint = True
start_time = time.time()
pngOpt = PngOptions()
pngOpt.compression_level = 9
pngOpt.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
with PsdImage.load(sourceFile, opt) as img:
img.save(outputFile, pngOpt)
elapsed_time = time.time() - start_time
# 旧值 = 193300
# 新值 = 55500
time_in_sec = int(elapsed_time * 1000)
if time_in_sec > 100000:
raise Exception("处理时间过长")
PSDPYTHON-36. 打开文档时出现“图像加载失败”异常
sourceFile1 = "PRODUCT.ai"
outputFile1 = "PRODUCT.png"
with AiImage.load(sourceFile1) as image:
image.save(outputFile1, PngOptions())
sourceFile2 = "Dolota.ai"
outputFile2 = "Dolota.png"
with AiImage.load(sourceFile2) as image:
image.save(outputFile2, PngOptions())
sourceFile3 = "ARS_novelty_2108_out_01(1).ai"
outputFile3 = "ARS_novelty_2108_out_01(1).png"
with AiImage.load(sourceFile3) as image:
image.save(outputFile3, PngOptions())
sourceFile4 = "bit_gear.ai"
outputFile4 = "bit_gear.png"
with AiImage.load(sourceFile4) as image:
image.save(outputFile4, PngOptions())
sourceFile5 = "test.ai"
outputFile5 = "test.png"
with AiImage.load(sourceFile5) as image:
image.save(outputFile5, PngOptions())
PSDPYTHON-37. 修复保存具有 Stroke Pattern 的 psd 文件
sourceFile = "StrokeShapePattern.psd"
outputFile = "StrokeShapePattern_output.psd"
newPatternBounds = Rectangle(0, 0, 4, 4)
guid = str(uuid.uuid4())
newPatternName = "$$$/Presets/Patterns/HorizontalLine1=Horizontal Line 9\0"
newPattern = [
Color.aqua.to_argb(), Color.red.to_argb(), Color.red.to_argb(), Color.aqua.to_argb(),
Color.aqua.to_argb(), Color.white.to_argb(), Color.white.to_argb(), Color.aqua.to_argb(),
Color.aqua.to_argb(), Color.white.to_argb(), Color.white.to_argb(), Color.aqua.to_argb(),
Color.aqua.to_argb(), Color.red.to_argb(), Color.red.to_argb(), Color.aqua.to_argb(),
]
with PsdImage.load(sourceFile) as img:
image = cast(PsdImage, img)
shapeLayer = cast(ShapeLayer, image.layers[1])
strokeInternalFillSettings = shapeLayer.fill
pattResource = None
for globalLayerResource in image.global_layer_resources:
pattResource = as_of(globalLayerResource, PattResource)
if pattResource is not None:
patternItem = pattResource.patterns[0] # Stroke internal pattern data
patternItem.pattern_id = guid
patternItem.name = newPatternName
patternItem.set_pattern(newPattern, newPatternBounds)
break
strokeInternalFillSettings.pattern_name = newPatternName
strokeInternalFillSettings.pattern_id = guid + "\0"
shapeLayer.update()
image.save(outputFile)
# 检查更改的数据.
with PsdImage.load(outputFile) as img:
image = cast(PsdImage, img)
shapeLayer = cast(ShapeLayer, image.layers[1])
strokeInternalFillSettings = shapeLayer.fill
assert guid.upper() == strokeInternalFillSettings.pattern_id
assert newPatternName == strokeInternalFillSettings.pattern_name + "\0"
PSDPYTHON-38. 当使用 ReplaceContents 时,智能对象中的文本样式不正确
inputFile = "source.psd"
output2 = "output.png"
psdLoadOptions = PsdLoadOptions()
psdLoadOptions.load_effects_resource = True
with PsdImage.load(inputFile, psdLoadOptions) as image:
psdImage = cast(PsdImage, image)
smartObject = cast(SmartObjectLayer, psdImage.layers[1])
smartObjectImage = cast(PsdImage, smartObject.load_contents(psdLoadOptions))
with smartObjectImage:
smartObject.replace_contents(smartObjectImage)
pngOpt = PngOptions()
pngOpt.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
psdImage.save(output2, pngOpt)
PSDPYTHON-39. [AI 格式] 修复 AI 文件中的 Cubic Bezier 渲染
sourceFile = "Typography.ai"
outputFilePath = "Typography.png"
with AiImage.load(sourceFile) as image:
image.save(outputFilePath, PngOptions())