Skip to main content
Participant
April 13, 2019
Question

Read clipping paths having low tolerance value.

  • April 13, 2019
  • 1 reply
  • 443 views

Hi ,

We are reading the clipping path stored in image using a third party library.For reading paths we are refereeing  to  Adobe Photoshop File Formats Specification

we are not able to read the path properly if the paths were  created  using low tolerance value (0.5 to 0.7)

During conversion of selection in work path, PS asks for a tolerance value which can vary from 0.5 to 10.0 pixels. So if we choose any value less than 0.8 pixels, we are not able to read the complete path in our application.For any value of tolerance between 0.8 to 10.0 (both inclusive), we are able to reader the path properly.

code snippet -

byte[] readPath( tree)

        {

            Byte[] pathData = null;

            try

            {

                bool nextArrayIsPathData = false;

                for (int i = 0; i < tree.Children.Count; i++)

                {

                    // If the child is a leaf (where the data lives), then we parse the data.

                    if (tree.Children is Leaf)

                    {

                        Leaf leaf = (Leaf)tree.Children;

                        // If the data is an array get the serialized data, otherwise just get the data.

                        if (leaf.Data.GetType().IsArray)

                        {

                            if (nextArrayIsPathData == true)

                            {

                                return (Byte[])leaf.Data;

                            }

                        }

                        else

                        {

                            //When Paths data is found leaf tag is 1008, however according to Adobe's spec. for path name leaf tag should be 2999

                            //See adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_17587

                       

                            if ((leaf.Tag == 1008) || (leaf.Tag == 2999))

                            {

                                nextArrayIsPathData = true;

                            }

                        }

                    }

                    // If the child is a tree (which holds more trees and/or leaves), then recursively call the function.

                    else if (tree.Children is Tree)

                    {

                        Tree tree2 = tree.Children;

                        if (pathData == null)

                        {

                            pathData = readPath(tree2);

                        }

                    }

                }

            }

            catch (Exception ex)

            {

             

                throw ex;

            }

            return pathData;

        }

Can you please let us know why we are facing the issue in case of low tolerance value? and is there any workaround for this issue?

Thank you in advance.

Regards,

Mithun

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
April 13, 2019
Can you please let us know why we are facing the issue in case of low tolerance value?

This is a user Forum, so you are not really addressing Adobe here, even though some Adobe employees thankfully have been dropping by.

Maybe you should ask on the Photoshop SDK Forum.

Photoshop Plugin and Companion App SDK

In any case I suspect the way a Path was created is irrelevant but the number of PathPoints may differ wildly.

To verify you could create a Work Path with a 0.5 tolerance based on a simple rectangular selection (which should come out with four points) and see if that processes properly in your software,

Participant
April 13, 2019

yes with simple rectangular section  i was able to process the path properly but in case if there are large number of path points I am not able to process the path