Copy link to clipboard
Copied
Is it possible to export guides from photoshop to use in other Adobe programs?
I need to draw guides with some gutters in Illustrator and can't figure out how without doing manually.....
Any advice?
Thanks in advance
My humble addition to the great script from @c.pfaffenbichler is to automatically export the paths to the desktop in Illustrator format. The .Ai file will be opened automatically, ready to select all and a conversion to guides (CMD/CTRL + 5). These last two steps could be automated with some BridgeTalk code, passing the script steps between Photoshop and Illustrator into a hybrid script:
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-export-guides-is-it-possible/m-p/1
...
Open the new Illustrator file. Drag the Direct Selection Tool over your document to locate and select the paths, one by one. With snapping on, drag your guide from the ruler to each path.
By @Lumigraphics
In Illustrator you don't need to work nearly that hard. 😊 Instead, select all of the paths then use Cmd+5 (Ctrl+5 for Windows) to convert all the paths to guides.
Jane
Copy link to clipboard
Copied
Hi @S01200
Thanks for reaching out.
It is not possible to export guides from Photoshop and use them in other programs.
For Adobe Illustrator, you can use the grids and guides in the application. Check this: https://helpx.adobe.com/illustrator/using/rulers-grids-guides-crop-marks.html.
Let us know if it helps.
Ranjisha
Copy link to clipboard
Copied
Thank you. I wish Illustrator has a function like Photoshop to create guides easily, though.
Copy link to clipboard
Copied
Not directly, however, paths can be exported to Illustrator and Illustrator can convert paths to guides. But this is a bit convoluted.
I'm not aware of a script to convert guides to paths in Photoshop, only guides to raster lines.
You can draw lines, rectangles, ellipses and other more complex paths directly in Illustrator and create guides from them.
I'd look into Illustrator native features or scripts.
Copy link to clipboard
Copied
Thank you. I'll look into 3rd party scripts to save time.
Copy link to clipboard
Copied
Before Photoshop had the guide layout command, people used actions or scripts such as:
There appears to be an Illustrator version.
Here is another option:
https://o2creative.co.nz/shop/Guides_PowerScript
If you search the Illustrator forum you'll likely find other scripts.
Copy link to clipboard
Copied
One can use a Script to output a txt-file with the numbers (and whatever) to use with a Script in another application (if that application offers Scripting functionality).
For Illustrator and Indesign one could even use BridgeTalk to address them in the same Script that works in Photoshop.
But without some experience with JavaScript and the involved DOMs it would seem difficult.
What are you actually trying to do?
Please post screenshots/sketches to clarify.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I tried, however it is beyond my abilities - how hard is it to make a script to loop over all guides and place a simple start/finish pathItem on each guide to the canvas extents?
This would seem to be useful if not only for this use case, but possibly others as well.
Copy link to clipboard
Copied
It’s feasible.
Edited to create a Shape Layer
// create a path based on the guides;
// 2023, use at your own risk;
#target photoshop
if (app.documents.length > 0 && app.activeDocument.guides.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
var myDocument = app.activeDocument;
var theGuides = collectGuides();
//alert (theGuides.join("\n"));
var theArray = new Array;
for (var m = 0; m < theGuides[0].length; m++) {
var theW = Number(myDocument.width);
var thisOne = Number(theGuides[0][m]);
theArray.push([[[0,thisOne],[0,thisOne],[0,thisOne],false],[[theW,thisOne],[theW,thisOne],[theW,thisOne],false],true,1737])
};
for (var n = 0; n < theGuides[1].length; n++) {
var theH = Number(myDocument.height);
var thisOne = Number(theGuides[1][n]);
theArray.push([[[thisOne,0],[thisOne,0],[thisOne,0],false],[[thisOne,theH],[thisOne,theH],[thisOne,theH],false],true,1737])
};
var thePath = createPath2022 (theArray, String(timeString()));
myDocument.pathItems[thePath-1].select();
shapeLayerWithStroke (2, 0, 0, 0);
app.preferences.rulerUnits = Units.POINTS;
};
////// function //////
function collectGuides () {
// set to pixels;
var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// collect guides;
var theArray1 = new Array;
var theArray2 = new Array;
for (var m = 0; m < myDocument.guides.length; m++) {
//theArray.push([myDocument.guides[m].coordinate, myDocument.guides[m].direction]);
if (myDocument.guides[m].direction == Direction.HORIZONTAL) {theArray1.push(myDocument.guides[m].coordinate)}
else {theArray2.push(myDocument.guides[m].coordinate)}
};
app.preferences.rulerUnits = originalRulerUnits;
app.preferences.rulerUnits = Units.POINTS;
return ([theArray1, theArray2]);
};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2022(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// thanks to xbytor;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Path'), cTID('WrPt'));
desc1.putReference(sTID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
list3.putObject(cTID('Pthp'), desc4);
};
desc3.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc3);
desc2.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc2);
};
desc1.putList(cTID('T '), list1);
executeAction(cTID('setd'), desc1, DialogModes.NO);
// name work path;
var desc30 = new ActionDescriptor();
var ref6 = new ActionReference();
var idPath = charIDToTypeID( "Path" );
ref6.putClass( idPath );
desc30.putReference( charIDToTypeID( "null" ), ref6 );
var ref7 = new ActionReference();
ref7.putProperty( idPath, charIDToTypeID( "WrPt" ) );
desc30.putReference( charIDToTypeID( "From" ), ref7 );
desc30.putString( charIDToTypeID( "Nm " ), thePathsName );
executeAction( charIDToTypeID( "Mk " ), desc30, DialogModes.NO );
/// get index;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("itemIndex"));
ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var pathDesc = executeActionGet(ref);
app.preferences.rulerUnits = originalRulerUnits;
return pathDesc.getInteger(stringIDToTypeID("itemIndex"))
};
////// create shape layer with stroke and no fill //////
function shapeLayerWithStroke (theWidth, theR, theG, theB) {
try {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc23 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref8 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref8.putClass( idcontentLayer );
desc23.putReference( idnull, ref8 );
var idUsng = charIDToTypeID( "Usng" );
var desc24 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc25 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var idRd = charIDToTypeID( "Rd " );
var idGrn = charIDToTypeID( "Grn " );
var idBl = charIDToTypeID( "Bl " );
var idRGBC = charIDToTypeID( "RGBC" );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc24.putObject( idType, idsolidColorLayer, desc25 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc28 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc28.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc28.putBoolean( idstrokeEnabled, true );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc28.putBoolean( idfillEnabled, false );
/* srtoke width */
var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
var idPxl = charIDToTypeID( "#Pxl" );
desc28.putUnitDouble( idstrokeStyleLineWidth, idPxl, theWidth );
var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
desc28.putUnitDouble( idstrokeStyleLineDashOffset, idPxl, 0.000000 );
var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
desc28.putDouble( idstrokeStyleMiterLimit, 100.000000 );
/* aöognment */
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );
desc28.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );
/* stroke color */
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc29 = new ActionDescriptor();
var desc30 = new ActionDescriptor();
desc30.putDouble( idRd, theR );
desc30.putDouble( idGrn, theG );
desc30.putDouble( idBl, theB );
desc29.putObject( idClr, idRGBC, desc30 );
desc28.putObject( idstrokeStyleContent, idsolidColorLayer, desc29 );
desc24.putObject( idstrokeStyle, idstrokeStyle, desc28 );
desc23.putObject( idUsng, idcontentLayer, desc24 );
var idLyrI = charIDToTypeID( "LyrI" );
desc23.putInteger( idLyrI, 15 );
executeAction( idMk, desc23, DialogModes.NO );
} catch (e) {}
};
////// function to get the date //////
function timeString () {
var now = new Date();
return now.getTime()
};
Copy link to clipboard
Copied
Thank you, that is fantastic! I can see why this was beyond my current abilities! :]
Copy link to clipboard
Copied
My humble addition to the great script from @c.pfaffenbichler is to automatically export the paths to the desktop in Illustrator format. The .Ai file will be opened automatically, ready to select all and a conversion to guides (CMD/CTRL + 5). These last two steps could be automated with some BridgeTalk code, passing the script steps between Photoshop and Illustrator into a hybrid script:
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-export-guides-is-it-possible/m-p/13635116
*/
// create a path based on the guides;
// 2023, use at your own risk;
#target photoshop
if (app.documents.length > 0 && app.activeDocument.guides.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
var myDocument = app.activeDocument;
var theGuides = collectGuides();
//alert (theGuides.join("\n"));
var theArray = new Array;
for (var m = 0; m < theGuides[0].length; m++) {
var theW = Number(myDocument.width);
var thisOne = Number(theGuides[0][m]);
theArray.push([[[0, thisOne], [0, thisOne], [0, thisOne], false], [[theW, thisOne], [theW, thisOne], [theW, thisOne], false], true, 1737])
};
for (var n = 0; n < theGuides[1].length; n++) {
var theH = Number(myDocument.height);
var thisOne = Number(theGuides[1][n]);
theArray.push([[[thisOne, 0], [thisOne, 0], [thisOne, 0], false], [[thisOne, theH], [thisOne, theH], [thisOne, theH], false], true, 1737])
};
var thePath = createPath2022(theArray, "Paths from Guides");
myDocument.pathItems[thePath - 1].select();
app.preferences.rulerUnits = Units.POINTS;
// Export paths to desktop in Illustrator format
var docName = myDocument.name.replace(/\.[^\.]+$/, '');
var newFile = File("~/Desktop" + '/' + docName + '_Paths' + '.ai');
var expOptions = new ExportOptionsIllustrator();
expOptions.path = IllustratorPathType.ALLPATHS;
myDocument.exportDocument(newFile, ExportType.ILLUSTRATORPATHS, expOptions);
activeDocument.pathItems.getByName("Paths from Guides").remove();
// Open the exported file
try {
var openPathsFile = File(newFile);
openPathsFile.execute();
} catch (e) {
alert("Error!" + "\r" + e + ' ' + e.line);
}
};
////// function //////
function collectGuides() {
// set to pixels;
var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.POINTS;
// collect guides;
var theArray1 = new Array;
var theArray2 = new Array;
for (var m = 0; m < myDocument.guides.length; m++) {
//theArray.push([myDocument.guides[m].coordinate, myDocument.guides[m].direction]);
if (myDocument.guides[m].direction == Direction.HORIZONTAL) { theArray1.push(myDocument.guides[m].coordinate) }
else { theArray2.push(myDocument.guides[m].coordinate) }
};
app.preferences.rulerUnits = originalRulerUnits;
app.preferences.rulerUnits = Units.POINTS;
return ([theArray1, theArray2]);
};
////// create a path from collectPathInfoFromDesc2012-array //////
function createPath2022(theArray, thePathsName) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// thanks to xbytor;
cTID = function (s) { return app.charIDToTypeID(s); };
sTID = function (s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Path'), cTID('WrPt'));
desc1.putReference(sTID('null'), ref1);
var list1 = new ActionList();
for (var m = 0; m < theArray.length; m++) {
var thisSubPath = theArray[m];
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID('shapeOperation'), sTID('shapeOperation'), thisSubPath[thisSubPath.length - 1]);
var list2 = new ActionList();
var desc3 = new ActionDescriptor();
desc3.putBoolean(cTID('Clsp'), thisSubPath[thisSubPath.length - 2]);
var list3 = new ActionList();
for (var n = 0; n < thisSubPath.length - 2; n++) {
var thisPoint = thisSubPath[n];
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[0][0]);
desc5.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[0][1]);
desc4.putObject(cTID('Anch'), cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[1][0]);
desc6.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[1][1]);
desc4.putObject(cTID('Fwd '), cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Rlt'), thisPoint[2][0]);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Rlt'), thisPoint[2][1]);
desc4.putObject(cTID('Bwd '), cTID('Pnt '), desc7);
desc4.putBoolean(cTID('Smoo'), thisPoint[3]);
list3.putObject(cTID('Pthp'), desc4);
};
desc3.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc3);
desc2.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc2);
};
desc1.putList(cTID('T '), list1);
executeAction(cTID('setd'), desc1, DialogModes.NO);
// name work path;
var desc30 = new ActionDescriptor();
var ref6 = new ActionReference();
var idPath = charIDToTypeID("Path");
ref6.putClass(idPath);
desc30.putReference(charIDToTypeID("null"), ref6);
var ref7 = new ActionReference();
ref7.putProperty(idPath, charIDToTypeID("WrPt"));
desc30.putReference(charIDToTypeID("From"), ref7);
desc30.putString(charIDToTypeID("Nm "), thePathsName);
executeAction(charIDToTypeID("Mk "), desc30, DialogModes.NO);
/// get index;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("itemIndex"));
ref.putEnumerated(charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var pathDesc = executeActionGet(ref);
app.preferences.rulerUnits = originalRulerUnits;
return pathDesc.getInteger(stringIDToTypeID("itemIndex"))
};
Copy link to clipboard
Copied
Don't bother with all that.
Create a new Photoshop document. Drag out your guides to where you want them. Turn on snapping and draw a short path with the line tool, snapped to each guide. Once you have them all, File->Export->Paths to Illustrator.
Open the new Illustrator file. Drag the Direct Selection Tool over your document to locate and select the paths, one by one. With snapping on, drag your guide from the ruler to each path.
Its much faster than it sounds, you can recreate a complex guide layout in just a couple of minutes.
Copy link to clipboard
Copied
Open the new Illustrator file. Drag the Direct Selection Tool over your document to locate and select the paths, one by one. With snapping on, drag your guide from the ruler to each path.
By @Lumigraphics
In Illustrator you don't need to work nearly that hard. 😊 Instead, select all of the paths then use Cmd+5 (Ctrl+5 for Windows) to convert all the paths to guides.
Jane
Copy link to clipboard
Copied
Even better!
Copy link to clipboard
Copied
Oh, this is much quicker. Thanks for the great tip. It's super useful to my workflow!!
Copy link to clipboard
Copied
Oh, this is much quicker. Thanks for the great tip. It's super useful to my workflow!!
By @S01200
If you think that is fast, I'd suggest that you check out the script that I adapted from @c.pfaffenbichler
Copy link to clipboard
Copied
You have been given multiple workable options to achieve your goal, can you please mark one or more replies as correct?
Copy link to clipboard
Copied
One simple way to place Photoshop guides into AfterEffects. Create your guides in Photoshop > Save the .psd file > Import the .psd file into After Effects as a Composite > Guides are now in your After Effects file.
You can now View > Export Guides .... to save them, and re-use them in other Comps.
There may other ways, but this does work (Although if your Guides are coloured, this won't transfer to After Effects, yet)
Copy link to clipboard
Copied
Going off at a wee tangent, Bert Monroy used Illustrator to create guidlines for where the shadows would fall in his mamouth Times Square illustration, and transfered them to Photoshop. These would obviously be angled lines, and not suitable for converting to Photoshop Guides, but's interesting trivia if you like that sort of thing.
Copy link to clipboard
Copied
Guides in Illustrator work differently from those in Photoshop, Trevor. Any path can be converted to a guide (Cmd+5) and any guide can be converted to a path. In addition to angled, guides can be circles, squares, stars, etc. I would love to see PS guides get a remake!
Jane
Find more inspiration, events, and resources on the new Adobe Community
Explore Now