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

Fit frame to content but in Photoshop

Explorer ,
Jun 13, 2014 Jun 13, 2014

I feel as if someone out there must have asked for this already but a search didn't find it, so I'm asking. Sorry if it's been done before.

In Indesign, you can select "Fit frame to Content" and the text box will shrink to the size of the text. Has anyone written a script to do that in Photoshop?

(Please don't say something like, "Photoshop is for images, use Indesign for text and layout. Yes, I get that, but that's not the question I was asking.)

Thanks!

TOPICS
Actions and scripting
4.5K
Translate
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
Adobe
Enthusiast ,
Jun 14, 2014 Jun 14, 2014

In theory you could set artLayer.TextItem.widht/height to the values of the bounding box (have not tried, but docs say it's read-write). However the width and height are a bit challenging because they ignore transforms, i.e. if the text box has been resized. You'd have to fetch scale factors using action descriptors and calculate unscaled size and set that. See below discussion for details

https://forums.adobe.com/thread/1110456

Translate
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 ,
Jun 15, 2014 Jun 15, 2014

Which purpose is this intended to serve?

Translate
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 ,
Jun 16, 2014 Jun 16, 2014

I get PSD files from other people from time to time at work. A few of the other designers think you need a text box that's many hundreds of pixels long and tall to type one word, and other such scenarios. Its a pain to edit these files because I end up grabbing the giant text box instead of something else that's under it.

I would love a way to select the text layers and run something that makes the text boxes fit the words inside them.

Translate
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 ,
Jun 16, 2014 Jun 16, 2014

If it is about one-word-Type Layers might converting the Paragraph Text to Point Text not suffice?

Translate
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 ,
Jun 19, 2014 Jun 19, 2014

You know, of all the people I discussed this with, no one has ever mentioned trying this out. I did and it works pretty well for me. Thanks!

Translate
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 ,
Jun 20, 2014 Jun 20, 2014
LATEST
no one has ever mentioned trying this out. I did and it works pretty well for me.

Automating this based on whether type layers have just one line or on less than a certain number of characters might be possible.

Translate
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 ,
Jun 18, 2014 Jun 18, 2014

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 );

}

};

Translate
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 ,
Jun 19, 2014 Jun 19, 2014

As far as the scripting goes, I have no idea how to make them, just how to use them. Thanks for doing this though. Maybe I can give it to a friend of mine to see if he can finish it up. Thanks again for the help.

Translate
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