Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: Fit frame to content but in Photoshop

$
0
0

It seems to be possible to change a paragraph text’s bounds without affecting the type settings.

I have not bothered to evaluate the existing bounds, so you’d have to do quite some work on the Script yet but maybe this can provide a starting point.

// 2014, use at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

if (myDocument.activeLayer.kind == LayerKind.TEXT) {

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

var idsetd = charIDToTypeID( "setd" );

    var desc3 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idTxLr = charIDToTypeID( "TxLr" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref2.putEnumerated( idTxLr, idOrdn, idTrgt );

    desc3.putReference( idnull, ref2 );

    var idT = charIDToTypeID( "T   " );

        var desc4 = new ActionDescriptor();

            var list1 = new ActionList();

                var desc8 = new ActionDescriptor();

                var idTEXT = charIDToTypeID( "TEXT" );

                var idTEXT = charIDToTypeID( "TEXT" );

                var idbox = stringIDToTypeID( "box" );

                desc8.putEnumerated( idTEXT, idTEXT, idbox );

                var idbounds = stringIDToTypeID( "bounds" );

                    var desc10 = new ActionDescriptor();

                    var idTop = charIDToTypeID( "Top " );

                    desc10.putDouble( idTop, 0.000000 );

                    var idLeft = charIDToTypeID( "Left" );

                    desc10.putDouble( idLeft, 0.000000 );

                    var idBtom = charIDToTypeID( "Btom" );

// set height;

                    desc10.putDouble( idBtom, 90 );

                    var idRght = charIDToTypeID( "Rght" );

// set width;

                    desc10.putDouble( idRght, 154 );

                var idRctn = charIDToTypeID( "Rctn" );

                desc8.putObject( idbounds, idRctn, desc10 );

            var idtextShape = stringIDToTypeID( "textShape" );

            list1.putObject( idtextShape, desc8 );

        desc4.putList( idtextShape, list1 );

    var idTxLr = charIDToTypeID( "TxLr" );

    desc3.putObject( idT, idTxLr, desc4 );

executeAction( idsetd, desc3, DialogModes.NO );

}

};


Viewing all articles
Browse latest Browse all 27456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>