Skip navigation
Currently Being Moderated

How to read path data?

Apr 16, 2010 1:23 AM

Hello, I'm new to photoshop plugin development, and wondering how to read the path data in plugin? That is, the data generated by the pen tool.


  • Currently Being Moderated
    Apr 23, 2010 2:26 PM   in reply to igamenovoer


    From PIProperties.h



    * Contents of the indexed path in the format described

    * in the path resources documentation; (Complex, read-only).

    * The paths are indexed starting with zero. The data is stored in big

    * endian form. Refer to chapter 10 for more information on path data.


    #define propPathContents      'path'


    From the file formats document I get this. Hopefully that gets the answer for you!


    Path resource format


    Photoshop stores the paths saved with an image in an image resource block. These resource blocks consist of a series of 26-byte path point records, so the resource length should always be a multiple of 26.


    Photoshop stores its paths as resources of type 8BIM , with IDs in the range 2000 through 2999. These numbers should be reserved for Photoshop. The name of the resource is the name given to the path when it was saved.


    If the file contains a resource of type 8BIM with an ID of 2999, then this resource contains a Pascal-style string containing the name of the clipping path to use with this image when saving it as an EPS file.


    The path format returned by GetProperty() call is identical to what is described below. Refer to the IllustratorExport sample plug-in code to see how this resource data is constructed.


    Path points


    All points used in defining a path are stored in eight bytes as a pair of 32-bit components, vertical component first.


    The two components are signed, fixed point numbers with 8 bits before the binary point and 24 bits after the binary point. Three guard bits are reserved in the points to eliminate most concerns over arithmetic overflow. Hence, the range for each component is 0xF0000000 to 0x0FFFFFFF representing a range of -16 to 16. The lower bound is included, but not the upper bound.


    This limited range is used because the points are expressed relative to the image size. The vertical component is given with respect to the image height, and the horizontal component is given with respect to the image width. [ 0,0 ] represents the top-left corner of the image; [ 1,1 ] ([ 0x01000000,0x01000000 ]) represents the bottom-right.


    In Windows, the byte order of the path point components are reversed; you should swap the bytes when accessing each 32-bit value.


    Path records


    The data in a path resource consists of one or more 26-byte records. The first two bytes of each record is a selector to indicate what kind of path it is. For Windows, you should swap the bytes before accessing it as a short.

    Path data record types










    Closed subpath length record





    Closed subpath Bezier knot, linked





    Closed subpath Bezier knot, unlinked





    Open subpath length record





    Open subpath Bezier knot, linked





    Open subpath Bezier knot, unlinked





    Path fill rule record





    Clipboard record





    Initial fill rule record


    The first 26-byte path record contains a selector value of 6, path fill rule record. The remaining 24 bytes of the first record are zeroes. Paths use even/odd ruling. Subpath length records, selector value 0 or 3, contain the number of Bezier knot records in bytes 2 and 3. The remaining 22 bytes are unused, and should be zeroes. Each length record is then immediately followed by the Bezier knot records describing the knots of the subpath.


    In Bezier knot records, the 24 bytes following the selector field contain three path points (described above) for:


    the control point for the Bezier segment preceding the knot,


    the anchor point for the knot, and


    the control point for the Bezier segment leaving the knot.


    Linked knots have their control points linked. Editing one point modifies the other to preserve collinearity. Knots should only be marked as having linked controls if their control points are collinear with their anchor. The control points on unlinked knots are independent of each other. Refer to the Adobe Photoshop User Guide for more information.


    Clipboard records, selector=7 , contain four fixed-point numbers for the bounding rectangle (top, left, bottom, right), and a single fixed-point number indicating the resolution.


    Initial fill records, selector=8 , contain one two byte record. A value of 1 means that the fill starts with all pixels. The value will be either 0 or 1.

    Mark as:
  • Currently Being Moderated
    Aug 25, 2013 8:32 AM   in reply to igamenovoer

    Hi igamenovoer,


    Did you have any success with this?



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points