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

Create a bubble below the text based on an existing image by magic wand script?

Explorer ,
Nov 24, 2022 Nov 24, 2022

Copy link to clipboard

Copied

Hello, I work as a comic editor and my job is to put translated text in the middle of the dialogue bubbles. My files sometimes have built-in text layers or not, sometimes they are rasterized layers. To turn off all rasterized text is really annoying, because they usually don't arrange in a certain order, and there are hundreds of layers.

Untitled-1.jpg

So I usually use magic wand (all layers mode) to select the boxes, then modify the selection and fill them at new layer (I recorded this action so it's alright).

It takes quite a while to select each bubble one by one. Is there a way to automatically get the selection outside a text layer using magic wand script? I could play it after setting the text and use the selection for aligning, too, or to handle broken dialog boxes like this: image_2022_11_15T08_49_12_432Z.png

TOPICS
Actions and scripting , Windows

Views

2.3K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Dec 17, 2022 Dec 17, 2022

Please try this. 

// apply magic wand tool at center of active layer’s bounds;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
	var theLayer = activeDocument.activeLayer;
	var theBounds = getBounds();
	theLayer.visible = false;
	var originalRulerUnits = app.preferences.rulerUnits;
	app.preferences.rulerUnits = Units.POINTS;
	useMagicWand2022 ([theBounds[3], theBounds[4]]);
// reset;
	theLayer.visible = true;
	app.preferences.rulerUnits = originalRulerUnits;
};
/////////////////
...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

I don't have a script for you that creates a bubble after you've selected your text layers, but here's a suggestion for the text selection.

 

In Photoshop, select the text that you want in bubbles and assign their layers a color so that you can display only them by doing the following:

  1. In the Layers panel, click the T to the right of the dropdown menu that by default shows Kind to filter the layers so that only text layers are shown.
  2. Select all the text layers in the Layers panel.
  3. Right-click and select a color name to label the text layers.
  4. Toggle off the Text filter to see the rest of the layers.
  5. Use the Move tool with Auto-Select selected and the dropdown menu set to Layer in the Options bar to manually select any rasterized text layers.
  6. Right-click again and select the same color name that you used in step 3.

 

Then you can filter the layers by the color by doing the following:

  1. At the top of the Layers panel, change the dropdown menu from Kind to Color.
  2. In the dropdown menu that appears to the right of Color, select the color that you assigned to the text layers.

 

 

 

Votes

Translate

Translate

Report

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 ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Thank you so much, but I think that's not what I'm aiming for. My goal is to remove the existing text in the speech bubble by adding a layer of color above it, not to hide them one by one (so there should be the part where I talk about the action that selects the area around the text). I could totally add a thick stroke to the new text layer, but that would ruin the original bubble. Anyway, thank you very much for your comment!

Votes

Translate

Translate

Report

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 ,
Nov 28, 2022 Nov 28, 2022

Copy link to clipboard

Copied

I fail to see Type Layers in your screenshot, could you elaborate on the actual process you have in mind? 

Votes

Translate

Translate

Report

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 ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Thank you and sorry for my late reply!

There is no type layer in my screenshot, they are rasterized layer which arranged in no order. Each comic page has hundreds of different layers like that, most are rasterized (including speech ones) so it's hard for me to find and hide all of them. I usually fill the speech bubbles on a new layer - using the magic wand to select the bubble's color (outside the text, within the bubble) and some action to make sure to fill the whole bubble. But I would sometimes use THAT selection for aligning the new text, too. So all I need is just a script, or an action to select the area within the bubbles below the selected text layer, so that I can skip the area selection step with magic wand.

Maybe this is a difficult thing, but I think this request is not too much. Thank you very much if you can help!

Votes

Translate

Translate

Report

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 ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

I don’t fully understand the process you describe, please post meaningful screenshots to illustrate the steps. 

Votes

Translate

Translate

Report

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 ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

Here I have clips about what I would do with the selection.

- Select bubble and run "clear the speech" action:

https://drive.google.com/file/d/14taBFTfGA4cemnIm1ykaCqlJVolSocv9/view?usp=share_link

 - Select bubble and run "aligning" action:

https://drive.google.com/file/d/15vJx-4xIpAMrujM8i4HXQU0TBVpURTgr/view?usp=share_link

Votes

Translate

Translate

Report

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 ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

Sorry for the line break, my wrong tap. I would set my translated text in bubble first, then get the selection (by magic wand) to do both actions at same time:

https://drive.google.com/file/d/1ktXc_Sakfr8CbhsrgBu5y_EfQlytLTIL/view?usp=share_link

Votes

Translate

Translate

Report

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
New Here ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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 ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

Please try this. 

// apply magic wand tool at center of active layer’s bounds;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
	var theLayer = activeDocument.activeLayer;
	var theBounds = getBounds();
	theLayer.visible = false;
	var originalRulerUnits = app.preferences.rulerUnits;
	app.preferences.rulerUnits = Units.POINTS;
	useMagicWand2022 ([theBounds[3], theBounds[4]]);
// reset;
	theLayer.visible = true;
	app.preferences.rulerUnits = originalRulerUnits;
};
////////////////////////////////////
////// use magic wand tool //////
function useMagicWand2022 (theCoord) {
	var idnull = charIDToTypeID( "null" );
	var idPxl = charIDToTypeID( "#Pxl" );
// select tool;
		var desc2 = new ActionDescriptor();
			var ref2 = new ActionReference();
			ref2.putClass( stringIDToTypeID( "magicWandTool" ) );
		desc2.putReference( idnull, ref2 );
		desc2.putBoolean( stringIDToTypeID( "dontRecord" ), true );
		desc2.putBoolean( stringIDToTypeID( "forceNotify" ), true );
	executeAction( charIDToTypeID( "slct" ), desc2, DialogModes.NO );
// apply tool;
		var desc2 = new ActionDescriptor();
			var ref2 = new ActionReference();
			ref2.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
		desc2.putReference( idnull, ref2 );
			var desc3 = new ActionDescriptor();
			desc3.putUnitDouble( charIDToTypeID( "Hrzn" ), idPxl, theCoord[0] );
			desc3.putUnitDouble( charIDToTypeID( "Vrtc" ), idPxl, theCoord[1] );
		desc2.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Pnt " ), desc3 );
		desc2.putInteger( charIDToTypeID( "Tlrn" ), 30 );
		desc2.putBoolean( charIDToTypeID( "AntA" ), true );
		desc2.putBoolean( stringIDToTypeID("merged"), true);
	executeAction( charIDToTypeID( "setd" ), desc2, DialogModes.NO );
	};
////// bounds of active layer //////
function getBounds (theIndex) {
    var ref = new ActionReference();
    ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("bounds"));
/*ref.putIndex(stringIDToTypeID("layer"), theIndex);*/
	ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
	var layerDesc = executeActionGet(ref);
    var theBounds = layerDesc.getObjectValue(stringIDToTypeID("bounds"));
    var theseBounds = [theBounds.getUnitDoubleValue(stringIDToTypeID("left")), theBounds.getUnitDoubleValue(stringIDToTypeID("top")), theBounds.getUnitDoubleValue(stringIDToTypeID("right")), theBounds.getUnitDoubleValue(stringIDToTypeID("bottom"))];
    var theW = theBounds.getUnitDoubleValue(stringIDToTypeID("right")) - theBounds.getUnitDoubleValue(stringIDToTypeID("left"));
    var theH = theBounds.getUnitDoubleValue(stringIDToTypeID("bottom")) - theBounds.getUnitDoubleValue(stringIDToTypeID("top"));
    var horCenter = theseBounds[0] + theW / 2;
    var verCenter = theseBounds[1] + theH / 2;
    return ([theseBounds, theW, theH, horCenter, verCenter])
};

Screenshot 2022-12-17 at 16.56.31.pngScreenshot 2022-12-17 at 16.56.51.png 

Votes

Translate

Translate

Report

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 ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

Wow, this worked to me! Thank you very much!

Votes

Translate

Translate

Report

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 ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

LATEST

You could try including the operations the Actions perform in the Sript, too.

It might be a little faster, but naturally it is not a necessity when the Actions themselves work satisfactorily. 

Votes

Translate

Translate

Report

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