In Indesign, you can double-click the text frame corners and your text field will crop so the frame is the same size as the text. Do any of you know if you have a similar function in Photoshop?
You can sort of do it by converting the paragraph text to point text and then back to paragraph text.
Type > Convert to point text and
Type > Convert to paragraph text. This method isn't very accurate. It leaves some of empty space in the text frame.
You can get something a bit more usable with scripts. I've made this script just for my own use so it's a bit rough around the edges:
active.textItem.height = 10000;(line 9) essentially just makes the text frame ridiculously tall before finalizing the text frame resize, so that hidden text is included in the resize. If removed, the script will just resize to what is visible, leaving hidden text alone.
Text flow may sometimes shift around a little.This happens in the gif on the 4th run time before I move the panel. Because of that the text box doesn't resize perfectly but running the script again in that situation solves that.
// Fit Text Frame To Content.jsx var rulerUnits = app.preferences.rulerUnits; app.preferences.rulerUnits = Units.POINTS; var doc = app.activeDocument; var active = doc.activeLayer; active.textItem.height = 10000; var bounds = active.boundsNoEffects; var top = bounds.value; var right = bounds.value; var bottom = bounds.value; var left = bounds.value; var width = right - left; var height = bottom - top; active.textItem.width = width; active.textItem.height = height; app.preferences.rulerUnits = rulerUnits;
You can launch scripts with a shortcut by putting them in the
Photoshop 2021/scripts/ folder, restarting PS and then giving it a shortcut from
Edit > Keyboard shortcuts... and in that window
Shortcuts for: Application menus (dropdown) > (below) File > Scripts (you have to scroll down quite a bit). Then just give it a shortcut. When you put scripts in the script folder, you can also launch them from the menu path
File > Scripts > ..., where you can also see the shortcut you give it, if you do.
Another way to launch scripts is by recording an action where you just launch the script (the way I did it in the gif): Start recording a new action, then either launch it from the
File > Scripts > ... list or
File > Scripts > Browse and launch it from anywhere in your HDD.
I also had the button mode on in the Actions panel. Just open the corner menu in the Actions panel and choose
Button mode. It can be handy, but FYI, you can also run actions in the regular mode by double clicking the action, if you press down Ctrl (on windows) or CMD (on Mac).