• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Exporting multiple paths from photoshop to multiple illustrator files

Explorer ,
Mar 13, 2014 Mar 13, 2014

Copy link to clipboard

Copied

Hello,

I have a task that I repeat often and I know there should be a way to write a photoshop script for the same. But my tech level in scripting is zero and I hoped somebody could possibly help me?

Background: I am an artist and I convert posterized image files to paths to feed to a CNC laser cutter. The image is broken down into separate layers (which are pasted back in hardcopy) and each layer is converted to outline paths (what is to be cut by the machine). for every image that i make there are about 3 - 8 paths that i create, each named a particular name. I then manually export each path one by one to an illustrator file (using Export >Paths to Illustrator), the files are named with a prefix_<the path name>.

sometimes a single large image is made up of 25 smaller sections (each section is a separate photoshop file) each with 3-8 paths, and it all adds up to a lot of manual labor each time.

is there a way to write a script that will export each individual path from a phtoshop file to a separate illustrator file with the name prefix_<path name> in a given directory (or a foler on the desktop if that's too complicated)?

I have searched the web but did not find a result that addresses this particular need. And as i've mentioned my scripting knowledge is not good enough to create/modify myself.

Thanks in advance.....

TOPICS
Actions and scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Mar 14, 2014 Mar 14, 2014

Avinash,

in my opinion Photoshop is not the optimal tool for your task. I would use Adobe Illustrator,

Live Trace or Image Trace (since CS6).

The vectorization of a raster image is fully under control by many parameters. Export as EPS

shows in the text file blocks like this:

991.532 1.85205 mo
993.008 1.61035 992.592 3.26025 992.643 4.44482 cv
991.515 4.21387 990.75 3.62207 990.791 2.22217 cv
991.221 2.28271 991.45 2.14063 991.532 1.85205 cv
cp
.031373 .65098 .501961 0 cmyk
ef

mo = moveto

cv = curveto (Béz

...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

This might cause issues with Vector Masks, but maybe it helps.

// export paths as ai;

// 2014, use at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

// getting the name and location

var docName = myDocument.name;

var basename = docName.match(/(.*)\.[^\.]+$/)[1];

var docPath = myDocument.path;

// export the paths;

for (var m = 0; m < myDocument.pathItems.length; m++) {

exportIllustratorPath (myDocument, myDocument.pathItems.name, docPath, basename);

}

};

////// function to save paths //////

function exportIllustratorPath (myDocument, pathName, docPath, basename) {

// =======================================================

var idExpr = charIDToTypeID( "Expr" );

    var desc10 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

        var desc11 = new ActionDescriptor();

        var idIn = charIDToTypeID( "In  " );

        desc11.putPath( idIn, new File( docPath+'/'+basename+"_"+pathName+".ai") );

        var idPthS = charIDToTypeID( "PthS" );

        var idPtSl = charIDToTypeID( "PtSl" );

        var idSngP = charIDToTypeID( "SngP" );

        desc11.putEnumerated( idPthS, idPtSl, idSngP );

        var idWhcP = charIDToTypeID( "WhcP" );

            var ref6 = new ActionReference();

            var idPath = charIDToTypeID( "Path" );

            ref6.putName( idPath, pathName );

        desc11.putReference( idWhcP, ref6 );

    var idIllustratorExportThisstringmakesmeunique = stringIDToTypeID( "Illustrator Export.  This string makes me unique!" );

    desc10.putObject( idUsng, idIllustratorExportThisstringmakesmeunique, desc11 );

executeAction( idExpr, desc10, DialogModes.NO );

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

Thank you for the help....

When executing the script I get this error for the last line of the script.

I'm on Photoshop 14.2.1 x64

Is there something i'm doing wroing?

Thanks again for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

2014-03-14 10.06.44 pm.png

sorry.... new to the forums, still finding my way around the interface....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

When executing the script I get this error for the last line of the script.

The Script runs fine here.

Could you post a screenshot with the Paths Panel visible?

Are you talking Paths or Vector Masks, anyway?

G.Hoffmann’s recommendation regarding Illustrator may be valid, though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

2014-03-15 09.14.38 pm.png

that's how my paths and layers panels look...

i will look into doing this in Illustrator. am less at ease there which is why i do in PS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

....there are no vector masks or layer masks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Could you post a jpg with the paths?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

SN2.jpg

like so? i presume the path data is still on the jpeg....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Works fine for me …

exportPaths.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

ok thank you very much.... i try and figure out what is going on slowly.....

thanks again.

just to confirm i did it right, i cut paste your script as plain text in textedit and save as .jsx

and load that as the script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

sorry sorry.... i'm making a mess marking correct and helpful......

sorry. my first time on the forum.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

I would have used ExtendScript Toolkit instead of TextEdit, but it should work nonetheless.

Please try ExtendScript Toolkit, there you can trigger the Script with the »play-button« without having to save it after each edit.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 17, 2014 Mar 17, 2014

Copy link to clipboard

Copied

LATEST

.... there must have been a formatting error somewhere.

downloaded Extendscript Tookit and saved your script from there.

it worked perfectly.

Thank you very much.

Thank you mr. hoffmann also.

Avinash.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

Avinash,

in my opinion Photoshop is not the optimal tool for your task. I would use Adobe Illustrator,

Live Trace or Image Trace (since CS6).

The vectorization of a raster image is fully under control by many parameters. Export as EPS

shows in the text file blocks like this:

991.532 1.85205 mo
993.008 1.61035 992.592 3.26025 992.643 4.44482 cv
991.515 4.21387 990.75 3.62207 990.791 2.22217 cv
991.221 2.28271 991.45 2.14063 991.532 1.85205 cv
cp
.031373 .65098 .501961 0 cmyk
ef

mo = moveto

cv = curveto (Bézier path)

cp = closepath

cmyk = color

ef = eofill (filling mode)

Occasionally, for straight lines:

li = lineto

Ignoring color and fill mode, it should be "simple" to extract the Bézier path information. 

Why is it necessary to separate all these paths into single files?

The laser cutting can be controlled for the whole job in one flow, because moveto

and closepath are equivalent to 'move without cutting' and 'end of cutting this path'.

Of course I'm lacking knowledge of your actual task. Please consider my contribution

as a suggestion for an alternative.

Best regards --Gernot Hoffmann

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

Dear Hoffmann,

Thank you for the reply.

The image is cut scale by scale from the posterized image and then repasted back again scale by scale in hardcopy. So it's a bit like the layers in photoshop but in paper. That is why they are to be in separate files as each scale is cut on a separate sheet of paper.

What you mention is more technical than i can follow easily. I will take your suggestion and explore the possibilty of using Illustrator instead.

I apologize if the way i wrote sounds, odd or strange.

Thanking you,

Avinash.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 14, 2014 Mar 14, 2014

Copy link to clipboard

Copied

I clarify my task, suggestions to automate part of the workflow would very welcome.

i use an example.... the image below is in 3 scales of grey.

2014-03-15 05.03.45 am.png

my aim is to construct a piece where the image is recreated through physical layers.

for this image i require 4 physical layers (with L004 being the bottom most layer and L0001 being the top most). the parts in red are to be cut out and have to be made into paths from these source bitmaps. the unique name of the path tells me when cutting what  paper to feed and which layer i'm working on.

2014-03-15 05.06.25 am.png

this is a simple example, but it can get confusing and laborious when there are more scales and layers. My problem isn't so much in converting to a path from bitmap, with an appropriate tolerance value it usually works fine. What i do is load the multiple bitmaps as layers in PS and make the paths. i just need to be able to output each of the red sections from each bitmap as separate ai files (each layer can contain several paths and contains both 'move without cutting' and 'end of cutting this path' info).

Thanks.

ps. for whatever reason i'm not good in public forums as a persona and tend to avoid speaking much as i can. sorry if you misunderstood me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

(1)

http://en.wikipedia.org/wiki/Jigsaw_puzzle

(2)

http://en.wikipedia.org/wiki/Printed_circuit_board

(3)

http://www.lpkf.de/produkte/rapid-pcb-prototyping/software/circuitcam-pcb.htm

----

Thanks for providing the images. I thought you were planning to produce jigsaw puzzles (1),

but now I see: printed circuit boards (PCBs), (2).

In my opinion your workflow contains a logical bug: the layers are combined in one flat

image and distinguishable only by colors and, concerning the holes only by topological

analysis: a black circle inside a white eyelet is a drill hole.

By eyelet I mean an annular or quadratic ring, sometimes called pad.

If the design was made by adhesive tape (your design looks so) then one uses normally

two plastic sheets, one for the top layer, another for the bottom layer. Drill holes have

to be identified by human 'pattern recognition'.

If the design is made by CAD, then the working piece is separated from the beginning

by layers: top, bottom, holes, text, varnish (for a double sided connected-through PCB).

Considering this, late separation of layers is obsolete, in my humble opinion.

Before we, nevertheless, discuss the possibilities of Photoshop or Illustrator, please explain:

What's the material? You're talking of paper, but normally we have copper on plastic.

How are the conductor tracks separated? By lasering a 'stroke' around the contour of a

contiguous area (tracks + eyelets) or by lasering a 'fill' anywhere outside these areas,

leaving only the red parts?

I think there are a couple of commercial solutions for CAD–CAM in this field already

available, e.g. (3). 

Best regards --Gernot Hoffmann

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Hello,

so sorry.... that was a very misleading example.....

my work is for a purely visual effect and has no practical function. I've been making digital artwork with a lot of layer masks and layers, flattening them and getting an inkjet output. at a certain point i wondered if it was possible to recreate the layer masks physically on paper too, and layer them one on top of the other like i would do in softcopy.

so from this source:

2014-03-15 04.01.10 pm.png

it looks like this in hardcopy on paper (just as a example).

2014-03-15 04.01.56 pm.png

to avoid floating islands of the image from falling off the image edge when cut, a friend of mine helped me write some java code to break the image into layers that are connected always to the edge of the frame. it outputs bitmaps like this.... a four grayscale image can output many layers depending on how many 'islands' there are.

2014-03-15 04.02.43 pm.png

the red indicates which parts of the image need to get cut on each layer. once i have all the layers cut on paper, i just glue them all back one by one in the same order to achive the preview image above.

it's a lot of work, just for a visual effect and has no practical purpose.

i guess my initial question was basic which i didn't state well. in the PS scripts there is one for 'export layers to file'. i just wondered if it was possible to have a similar one for 'export paths to files'. pehaps this can be done via illustrator better and that is something i haven't looked into well enough.

the production of each image can take a long time and is very repetivie. just wanted to try and automate some parts of the workflow if i can....

thanks for taking the time to reply. and sorry about the misleading example.

Avinash.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Thanks for the clarification and further information. This will hopefully enable

the scripting and layer mask experts here to help you further, and as well me

concerning the application of Illustrator.

There is one issue which I'm still not understanding: how do you decide which

parts of the graphic belong to one layer?

Meanwhile you may have a look here, an application of Live Trace by Illustrator:

http://docs-hoffmann.de/casamunsell24062012.pdf

3 MBytes. Explanation in German and English on the first pages.

Best regards --Gernot Hoffmann

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Thank you for sharing that. That's another league of precision altogether....

I have used live trace in Illustrator, not very much but mostly for simple non critical work. I would like one day to trace an image to vector for a really large enlargemt..

regarding your question about which sections belong to one layer, my friend insisted it was a simple logic but i didn't fully follow. I think the code looks for the largest amount of connected color, puts that in one layer, takes the next largest section of connected color + the previous layer and puts that in the second and so forth.

example.jpg

so the 1st is the image and the following 3 are how it's broken down (orange indicates cutting). the circle is an 'island' and will drop off the frame of the image if cut in 2 layers. so it's pushed into the third.

thanks again for all your time and help.

Avinash.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

i'm making a mess marking correct and helpful

Don’t sweat it, many users don’t seem to bother with those rankings at all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines