Skip to main content
try67
Community Expert
Community Expert
July 29, 2009
Question

Apply stroke to text (JS, CS2 or higher)

  • July 29, 2009
  • 1 reply
  • 2799 views

Hi all,

I'm having some problems applying a 3 points red stroke to a text layer using JS on PS-CS2 (or higher).

I've tried adapting xbyto's script ( http://ps-scripts.com/bb/viewtopic.php?p=2021#2021 ), but to no avail.

Any help is appreciated.

Cheers.

This topic has been closed for replies.

1 reply

Inspiring
July 29, 2009

The script in that post is for doing fine grain control of text styles within a text layer. If all you want to do is apply a 3px red stroke to the entire text layer, use a layer style and script listener code. You'll end up with something like this:

function stroke3pxRed() {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc39 = new ActionDescriptor();
        var ref13 = new ActionReference();
        ref13.putProperty( cTID('Prpr'), cTID('Lefx') );
        ref13.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
    desc39.putReference( cTID('null'), ref13 );
        var desc40 = new ActionDescriptor();
        desc40.putUnitDouble( cTID('Scl '), cTID('#Prc'), 100.000000 );
            var desc41 = new ActionDescriptor();
            desc41.putBoolean( cTID('enab'), true );
            desc41.putEnumerated( cTID('Styl'), cTID('FStl'), cTID('OutF') );
            desc41.putEnumerated( cTID('PntT'), cTID('FrFl'), cTID('SClr') );
            desc41.putEnumerated( cTID('Md  '), cTID('BlnM'), cTID('Nrml') );
            desc41.putUnitDouble( cTID('Opct'), cTID('#Prc'), 100.000000 );
            desc41.putUnitDouble( cTID('Sz  '), cTID('#Pxl'), 3.000000 );
                var desc42 = new ActionDescriptor();
                desc42.putDouble( cTID('Rd  '), 255.000000 );
                desc42.putDouble( cTID('Grn '), 0.000000 );
                desc42.putDouble( cTID('Bl  '), 0.000000 );
            desc41.putObject( cTID('Clr '), cTID('RGBC'), desc42 );
        desc40.putObject( cTID('FrFX'), cTID('FrFX'), desc41 );
    desc39.putObject( cTID('T   '), cTID('Lefx'), desc40 );
    executeAction( cTID('setd'), desc39, DialogModes.NO );
};

-X

try67
Community Expert
try67Community ExpertAuthor
Community Expert
July 29, 2009

Awesome. Cheers!

Can I ask how did you separate just this from the rest of the script

listener output?

When I applied a stroke and looked at the code, it was a huge function and I

couldn't really figure it out.

Inspiring
July 29, 2009

In xtools/apps, there is a script called 'LastLogEntry'. I have an action that runs the script. Whenever I need JS code for something I do in PS, I run this right after creating the style (or whatever). It pops up a dialog with the last entry in the Script Listener log and has a button called 'Fix' that reformats the code into something a bit more readable.

That one little script will do wonders for your productivity if you script PS on a regular basis.

-X