Aspose.PSD for .NET 19.5 - Release Notes

** 

Key Summary Category
PSDNET-133 Add support of Fill layers: Pattern Feature
PSDNET-138 Support of PtFlResource Feature
PSDNET-129 Implement correct Crop method for PSD files Feature
PSDNET-140 Support of VsmsResource Feature
PSDNET-121 Visible Layers in Visible SubFolder in Invisible Folder are rendered, but should not Bug
PSDNET-119 PSD (RGB mode 16 bit per channel) not properly converted to JPG Bug

Public API Changes

Added APIs:

  • T:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.Linked
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.Scale
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PointType
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PatternName
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PatternId
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.HorizontalOffset
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.VerticalOffset
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PatternData
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PatternWidth
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.IPatternFillSettings.PatternHeight
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.PatternFillSettings.AlignWithLayer
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.PatternFillSettings.PatternData
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.PatternFillSettings.PatternWidth
  • P:Aspose.PSD.FileFormats.Psd.Layers.FillSettings.PatternFillSettings.PatternHeight
  • T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.#ctor(System.String,System.String)
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Signature
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Key
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Length
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.PsdVersion
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.PatternName
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Offset
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Scale
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.IsLinkedWithLayer
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.AlignWithLayer
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.PatternId
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.Save(Aspose.PSD.StreamContainer,System.Int32)
  • F:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.PtFlResource.TypeToolKey
  • T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.#ctor(System.Byte[])
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.Paths
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.Version
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.IsDisabled
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.IsNotLinked
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.IsInverted
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.Signature
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.Length
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.PsdVersion
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPathDataResource.Save(Aspose.PSD.StreamContainer,System.Int32)
  • T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VsmsResource
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VsmsResource.#ctor(System.Byte[])
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VsmsResource.Key
  • F:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VsmsResource.TypeToolKey
  • M:Aspose.PSD.Image.DoAfterCreate(System.Int64@,System.Int64)
  • P:Aspose.PSD.ImageOptionsBase.BufferSizeHint
  • M:Aspose.PSD.Metered.GetConsumptionCredit

Removed APIs:

  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.Paths
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.Version
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.IsDisabled
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.IsNotLinked
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.IsInverted
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.Signature
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.Length
  • P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.PsdVersion
  • M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VmskResource.Save(Aspose.PSD.StreamContainer,System.Int32)

Usage examples:

PSDNET-133. Add support of Fill layers: Pattern

 // Add support of Fill layers: Pattern

    string sourceFileName = "PatternFillLayer.psd";

    string exportPath = "PatternFillLayer_Edited.psd";

    double tolerance = 0.0001;

    var im = (PsdImage)Image.Load(sourceFileName);

    using (im)

    {

         foreach (var layer in im.Layers)

         {

             if (layer is FillLayer)

             {

                  FillLayer fillLayer = (FillLayer)layer;

                  PatternFillSettings fillSettings = (PatternFillSettings)fillLayer.FillSettings;

                  if (fillSettings.HorizontalOffset != -46 || 

                      fillSettings.VerticalOffset != -45 || 

                      fillSettings.PatternId != "a6818df2-7532-494e-9615-8fdd6b7f38e5"||

                      fillSettings.PatternName != "$$$/Presets/Patterns/OpticalSquares=Optical Squares" ||

                      fillSettings.AlignWithLayer != true ||

                      fillSettings.Linked != true ||

                      fillSettings.PatternHeight != 64 ||

                      fillSettings.PatternWidth != 64 ||

                      fillSettings.PatternData.Length != 4096 ||

                      Math.Abs(fillSettings.Scale - 50) > tolerance) 

                      {

                          throw new Exception("PSD Image was read wrong");

                      }

                  // Editing 

                  fillSettings.Scale = 300;

                  fillSettings.HorizontalOffset = 2;

                  fillSettings.VerticalOffset = -20;

                  fillSettings.PatternData = new int[]

                  {

                       Color.Red.ToArgb(), Color.Blue.ToArgb(),  Color.Blue.ToArgb(),

                       Color.Blue.ToArgb(), Color.Red.ToArgb(),  Color.Blue.ToArgb(),

                       Color.Blue.ToArgb(), Color.Blue.ToArgb(),  Color.Red.ToArgb()

                  };

                  fillSettings.PatternHeight = 3;

                  fillSettings.PatternWidth = 3;

                  fillSettings.AlignWithLayer = false;

                  fillSettings.Linked = false;

                  fillSettings.PatternId = Guid.NewGuid().ToString();

                  fillLayer.Update();

                  break;

             }

         }

         im.Save(exportPath);

    }

PSDNET-138. Support of PtFlResource

  // Support of PtFlResource

    string sourceFileName = "PatternFillLayer.psd";

    string exportPath = "PtFlResource_Edited.psd";

    double tolerance = 0.0001;

    var im = (PsdImage)Image.Load(sourceFileName);

    using (im)

    {

         foreach (var layer in im.Layers)

         {

             if (layer is FillLayer)

             {

                var fillLayer = (FillLayer)layer;

                var resources = fillLayer.Resources;

                foreach (var res in resources)

                {

                    if (res is PtFlResource)

                    {

                        // Reading

                        PtFlResource resource = (PtFlResource)res;

                        if (

                            resource.Offset.X != -46 || 

                            resource.Offset.Y != -45 || 

                            resource.PatternId != "a6818df2-7532-494e-9615-8fdd6b7f38e5\0" ||

                            resource.PatternName != "$$$/Presets/Patterns/OpticalSquares=Optical Squares\0" ||

                            resource.AlignWithLayer != true ||

                            resource.IsLinkedWithLayer != true ||

                            !(Math.Abs(resource.Scale - 50) < tolerance)) {

                                throw new Exception("PtFl Resource was read incorrect");

                            }

                        // Editing

                        resource.Offset = new Point(-11, 13);

                        resource.Scale = 200;

                        resource.AlignWithLayer = false;

                        resource.IsLinkedWithLayer = false;

                        fillLayer.Resources = fillLayer.Resources;

                        // We haven't pattern data in PattResource, so we can add it.

                        var fillSettings = (PatternFillSettings)fillLayer.FillSettings;

                        fillSettings.PatternData = new int[]

                        {

                            Color.Black.ToArgb(),

                            Color.White.ToArgb(),

                            Color.White.ToArgb(),

                            Color.White.ToArgb(),

                        };

                        fillSettings.PatternHeight = 1;

                        fillSettings.PatternWidth = 4;

                        fillSettings.PatternName = "$$$/Presets/Patterns/VerticalLine=Vertical Line New\0";

                        fillSettings.PatternId = Guid.NewGuid().ToString() + "\0";

                        fillLayer.Update();

                    }

                    break;

                }

                break;

            }

         }

         im.Save(exportPath);

    } 

PSDNET-129. Implement correct Crop method for PSD files

             // Implement correct Crop method for PSD files.

            string sourceFileName = "1.psd";

            string exportPathPsd = "CropTest.psd";

            string exportPathPng = "CropTest.png";

            using (RasterImage image = Image.Load(sourceFileName) as RasterImage)

            {

                image.Crop(new Rectangle(10, 30, 100, 100));

                image.Save(exportPathPsd, new PsdOptions());

                image.Save(exportPathPng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });

            }

PSDNET-140. Support of VsmsResource

 // VsmsResource Support

        static void ExampleOfVsmsResourceSupport()

        {

            string sourceFileName = "EmptyRectangle.psd";

            string exportPath = "EmptyRectangle_changed.psd";

            var im = (PsdImage)Image.Load(sourceFileName);

            using (im)

            {

                var resource = GetVsmsResource(im);

                // Reading

                if (resource.IsDisabled != false ||

                    resource.IsInverted != false ||

                    resource.IsNotLinked != false ||

                    resource.Paths.Length != 7 ||

                    resource.Paths[0].Type != VectorPathType.PathFillRuleRecord ||

                    resource.Paths[1].Type != VectorPathType.InitialFillRuleRecord ||

                    resource.Paths[2].Type != VectorPathType.ClosedSubpathLengthRecord ||

                    resource.Paths[3].Type != VectorPathType.ClosedSubpathBezierKnotUnlinked ||

                    resource.Paths[4].Type != VectorPathType.ClosedSubpathBezierKnotUnlinked ||

                    resource.Paths[5].Type != VectorPathType.ClosedSubpathBezierKnotUnlinked||

                    resource.Paths[6].Type != VectorPathType.ClosedSubpathBezierKnotUnlinked)

                {

                        throw new Exception("VsmsResource was read wrong");

                }

                var pathFillRule = (PathFillRuleRecord)resource.Paths[0];

                var initialFillRule = (InitialFillRuleRecord)resource.Paths[1];

                var subpathLength = (LengthRecord)resource.Paths[2];

                // Path fill rule doesn't contain any additional information

                if (pathFillRule.Type != VectorPathType.PathFillRuleRecord || 

                initialFillRule.Type != VectorPathType.InitialFillRuleRecord ||

                initialFillRule.IsFillStartsWithAllPixels != false ||

                subpathLength.Type != VectorPathType.ClosedSubpathLengthRecord ||

                subpathLength.IsClosed != true ||

                subpathLength.IsOpen != false) 

                {

                    throw new Exception("VsmsResource paths were read wrong");

                }

                // Editing

                resource.IsDisabled = true;

                resource.IsInverted = true;

                resource.IsNotLinked = true;

                var bezierKnot = (BezierKnotRecord)resource.Paths[3];

                bezierKnot.Points[0] = new Point(0, 0);

                bezierKnot = (BezierKnotRecord)resource.Paths[4];

                bezierKnot.Points[0] = new Point(8039798, 10905191);

                initialFillRule.IsFillStartsWithAllPixels = true;

                subpathLength.IsClosed = false;

                im.Save(exportPath);

            }         

        }

        static VsmsResource GetVsmsResource(PsdImage image)

        {

            var layer = image.Layers[1];

            VsmsResource resource = null;

            var resources = layer.Resources;

            for (int i = 0; i < resources.Length; i++)

            {

                if (resources[i] is VsmsResource)

                {

                    resource = (VsmsResource)resources[i];

                    break;

                }

            }

            if (resource == null)

            {

                throw new Exception("VsmsResource not found");

            }

            return resource;

        }   

PSDNET-121: Visible Layers in Visible SubFolder in Invisible Folder are rendered, but should not

 // Visible Layers in Visible SubFolder in Invisible Folder are rendered, but shouldn't

            string sourceFileName = "ALotOfFolders.psd.psd";

            string outputFilePathJpg = "outALotOfFolders.jpg";

            string outputFilePathPsd = "outALotOfFolders.psd";

            var options = new PsdLoadOptions();

            using (PsdImage image = (PsdImage)Image.Load(sourceFileName, options))

            {

                image.Save(outputFilePathPsd, new PsdOptions(image));

                image.Save(outputFilePathJpg, new JpegOptions() { Quality = 100 });

            }

PSDNET-119. PSD (RGB mode 16 bit per channel) not properly converted to JPG

  // Psd not properly converted to jpg

            string sourceFileName = "in.psd";

            string exportPath = "outRgb.jpg";

            var options = new PsdLoadOptions();

            using (PsdImage image = (PsdImage)Image.Load(sourceFileName, options))

            {

                image.Save(exportPath, new JpegOptions() { Quality = 100 });

            }