Aspose.PSD for Python via .NET 24.4 - Release Notes
Contents
[
Hide
]
This page contains release notes forĀ Aspose.PSD for Python via .NET 24.4
Key | Summary | Category |
---|---|---|
PSDPYTHON-50 | [AI Format] Add XObjectForm resource handling | Feature |
PSDPYTHON-51 | Add Constructor for the ShapeLayer | Feature |
PSDPYTHON-52 | Fix conversion of Psd file from RGB to CMYK | Bug |
PSDPYTHON-53 | Specific PSD file can not be exported using Aspose.PSD | Bug |
Public API Changes
Added APIs:
- M:Aspose.PSD.FileFormats.Psd.PsdImage.AddShapeLayer
Removed APIs:
- None
Usage examples:
PSDPYTHON-50. [AI Format] Add XObjectForm resource handling
sourceFileName = "example.ai"
outputFilePath = "example_output.png"
with AiImage.load(sourceFileName) as image:
image.save(outputFilePath, PngOptions())
PSDPYTHON-51. Add Constructor for the ShapeLayer
def check ShapeLayerConstructor():
outputFile = "AddShapeLayer_output.psd"
with PsdImage(600, 400) as newPsd:
shapeLayer = newPsd.add_shape_layer()
newShape = generate_new_shape(newPsd.size)
newShapes = [newShape]
shapeLayer.path.set_items(newShapes)
shapeLayer.update()
newPsd.save(outputFile)
with PsdImage.load(outputFile) as img:
image = cast(PsdImage, img)
assert len(image.layers) == 2
shapeLayer = cast(ShapeLayer, image.layers[1])
internalFill = shapeLayer.fill
strokeSettings = shapeLayer.stroke
strokeFill = shapeLayer.stroke.fill
assert len(shapeLayer.path.get_items()) == 1
assert len(shapeLayer.path.get_items()[0].get_items()) == 3
assert internalFill.color.to_argb() == -16127182
assert strokeSettings.size == 7.41
assert not strokeSettings.enabled
assert strokeSettings.line_alignment == StrokePosition.CENTER
assert strokeSettings.line_cap == LineCapType.BUTT_CAP
assert strokeSettings.line_join == LineJoinType.MITER_JOIN
assert strokeFill.color.to_argb() == -16777216
def generate_new_shape(imageSize):
newShape = PathShape()
point1 = PointF(20, 100)
point2 = PointF(200, 100)
point3 = PointF(300, 10)
knot1 = BezierKnotRecord()
knot1.is_linked = True
knot1.points = [
Release_24_04_Tests.PointFToResourcePoint(point1, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point1, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point1, imageSize)
]
knot2 = BezierKnotRecord()
knot2.is_linked = True
knot2.points = [
Release_24_04_Tests.PointFToResourcePoint(point2, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point2, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point2, imageSize)
]
knot3 = BezierKnotRecord()
knot3.is_linked = True
knot3.points = [
Release_24_04_Tests.PointFToResourcePoint(point3, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point3, imageSize),
Release_24_04_Tests.PointFToResourcePoint(point3, imageSize)
]
bezierKnots = [
knot1,
knot2,
knot3
]
newShape.set_items(bezierKnots)
return newShape
def PointFToResourcePoint(point, imageSize):
ImgToPsdRatio = 256 * 65535
return Point(
int(round(point.y * (ImgToPsdRatio / imageSize.height))),
int(round(point.x * (ImgToPsdRatio / imageSize.width)))
)
def assert_are_equal(expected, actual, message=None):
if expected != actual:
raise Exception(message or "Objects are not equal.")
PSDPYTHON-52. Fix conversion of Psd file from RGB to CMYK
def checkConversionFromRgbToCmyk():
sourceFile = "frog_nosymb.psd"
outputFile = "frog_nosymb_output.psd"
with PsdImage.load(sourceFile) as image:
psdImage = cast(PsdImage, image)
psdImage.has_transparency_data = False
psdOptions = PsdOptions(psdImage)
psdOptions.color_mode = ColorModes.CMYK
psdOptions.compression_method = CompressionMethod.RLE
psdOptions.channels_count = 4
psdImage.save(outputFile, psdOptions)
with PsdImage.load(outputFile) as image:
psdImage = cast(PsdImage, image)
assert not psdImage.has_transparency_data
assert psdImage.layers[0].channels_count == 4
def assert_are_equal(expected, actual, message=None):
if expected != actual:
raise Exception(message or "Objects are not equal.")
def assert_are_equal(expected, actual, message=None):
if expected != actual:
raise Exception(message or "Objects are not equal.")
PSDPYTHON-53. Specific PSD file can not be exported using Aspose.PSD
sourceFile = "1966source.psd"
outputPng = "output.png"
loadOpt = PsdLoadOptions()
loadOpt.load_effects_resource = True
with PsdImage.load(sourceFile, loadOpt) as psdImage:
psdImage.save(outputPng, PngOptions())