Anchor points export script doesn't keep separated multiple shapes

Started by Nico99, March 16, 2017, 06:35:12 PM

Previous topic - Next topic

Nico99

Hi Phil
in some cases, when a path is composed by multiple shapes, the ancor point export script fails mixing them up. This happens because each group of points is not kept separated.
To clarify, please find attached a sample (it is a white tif with a path called MyPath).

As you know, in binary format, the path is saved as:

#header
3842494D07D0064D7950617468000000011E
0006000000000000000000000000000000000000000000000000

#fist shape
0000000400000000000000000000000000000000000000000000
0002001FFFFF0083D709001FFFFF0083D709001FFFFF0083D709
000200828F5B0083D70900828F5B0083D70900828F5B0083D709
000200828F5B001C28F500828F5B001C28F500828F5B001C28F5
0002001FFFFF001C28F5001FFFFF001C28F5001FFFFF001C28F5

#second shape
0000000400000000000000000000000000000000000000000000
0002009C28F500EE1478009C28F500EE1478009C28F500EE1478
000200F0A3D500EE147800F0A3D500EE147800F0A3D500EE1478
000200F0A3D5008A3D7000F0A3D5008A3D7000F0A3D5008A3D70
0002009C28F5008A3D70009C28F5008A3D70009C28F5008A3D00


Each set of point starts with an header, in this case:
0000000400000000000000000000000000000000000000000000

If I export the anchor points with the following command (exiftool ver. 10.46):
exiftool -config ./config_files/photoshop_paths.config -j -allpathpix test.tif

this is what I get:

[{
  "SourceFile": "test.tif",
  "PathPix7d0": "MyPath (103,25) (103,102) (22,102) (22,25) (186,122) (186,188) (108,188) (108,122)"
}]


As you can see there isn't any separator between the two sets and the 8 point are saved sequentially.

Any idea about how to solve this issue ?

Thanks
Nico

Phil Harvey

Hi Nico,

Sorry for the delay in responding.

I don't know exactly what you want, or why you say the export script fails.

What output do you want to see for your test file?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Nico99

Hi Phil
sorry if I was not clear.
What I meant is that, in that test image, there are two different shapes (two rectangles), belonging the same path name and the output of the script doesn't highlight that detail (as the binary does).
In my opinion, this output:
[{
  "SourceFile": "test.tif",
  "PathPix7d0": "MyPath (103,25) (103,102) (22,102) (22,25) (186,122) (186,188) (108,188) (108,122)"
}]


should be something like this:
[{
  "SourceFile": "test.tif",
  "PathPix7d0": "MyPath (103,25) (103,102) (22,102) (22,25) - (186,122) (186,188) (108,188) (108,122)"   #note the hyphen that separates the two shapes (any separator is fine)
}]


or like this:
[{
  "SourceFile": "test.tif",
  "PathPix7d0": ["MyPath (103,25) (103,102) (22,102) (22,25)", "MyPath (186,122) (186,188) (108,188) (108,122)"]  #an array of shapes
}]


or any other structure.

At the moment that information is lost.
My goal is to draw the path using the coordinates but you can immagine that, without such details, the results are quite different :)
Thanks
Nico

Phil Harvey

Hi Nico,

OK, this is easy.  There are so other codes that I am ignoring in the path record.  Current the config file shows only the Bezier knot coordinates, but there are "Open" and "Closed" paths too.  If you are drawing the paths I think this would be important information too.  Also, I am completely ignoring path fill records, clipboard records and fill rules in the path.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Nico99

You are right, open and close tag could be useful as well. Personally I don't need the fill rules, at least for the moment.
Thanks
Nico

Phil Harvey

OK, how about a dash for closed paths and some other character for open paths (any suggestions?).

Then your file will give this result:

exiftool -config config_files/photoshop_paths.config -userparam anchor -allpathpix -json ~/Desktop/test.tif
[{
  "SourceFile": "/Users/phil/Desktop/test.tif",
  "PathPix7d0": "MyPath - (103,25) (103,102) (22,102) (22,25) - (186,122) (186,188) (108,188) (108,122)"
}]


Give it a try... I've attached the updated config file below

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Nico99

Hi Phil
the example you provided works perfectly, + and - are great.
Thank you very much indeed.
Nico

Phil Harvey

Great.  This config file will be included in the next ExifTool release.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).