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

I need help to modify my PS script? " Open many jpg image Fill/paste"

New Here ,
Oct 04, 2022 Oct 04, 2022

var nm = "Auto_123";

var selected = get_selected_layers_id();

for (var i = 0; i < selected.length; i++)
{
select_layer(selected[i]);
app.activeDocument.activeLayer.name = nm;
}

select_layers(selected);

//////////////////////////////////////////////////////////////
function select_layer(id)
{
try {
var r = new ActionReference();
r.putIdentifier(stringIDToTypeID("layer"), id);

var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}

//////////////////////////////////////////////////////////////
function select_layers(ids)
{
try {
var r = new ActionReference();
for (var i = 0; i < ids.length; i++) r.putIdentifier(stringIDToTypeID("layer"), ids[i]);

var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);

executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}

//////////////////////////////////////////////////////////////
function get_selected_layers_id()
{
try {
var selected = new Array();

var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("targetLayersIDs"));
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var list = executeActionGet(r).getList(stringIDToTypeID("targetLayersIDs"));

for (var i = 0; i < list.count; i++) selected.push(list.getReference(i).getIdentifier());

return selected;
}
catch (e) { throw(e); }
}
// Cycle forwards through open doc windows
var idselect = stringIDToTypeID("select");
var desc410 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref119 = new ActionReference();
var iddocument = stringIDToTypeID( "document" );
ref119.putOffset( iddocument, 1 ); // -1 to cycle backwards through open doc windows
desc410.putReference( idnull, ref119 );
var iddocumentID = stringIDToTypeID( "documentID" );
executeAction( idselect, desc410, DialogModes.NO );
var doc;
var i;
var ii;
if (app.documents.length) {
for (i = 0; i < app.documents.length; i++) {
doc = app.documents[i];
if (/\.jpg$/i.test(doc.name)) {
app.activeDocument = doc;
break;
}
}
}
var id5 = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var id6 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id7 = charIDToTypeID( "Chnl" );
var id8 = charIDToTypeID( "fsel" );
ref1.putProperty( id7, id8 );
desc3.putReference( id6, ref1 );
var id9 = charIDToTypeID( "T " );
var id10 = charIDToTypeID( "Ordn" );
var id11 = charIDToTypeID( "Al " );
desc3.putEnumerated( id9, id10, id11 );
executeAction( id5, desc3, DialogModes.NO );

// =======================================================
var id12 = charIDToTypeID( "copy" );
executeAction( id12, undefined, DialogModes.NO );

// =======================================================
var id13 = charIDToTypeID( "setd" );
var desc4 = new ActionDescriptor();
var id14 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id15 = charIDToTypeID( "Chnl" );
var id16 = charIDToTypeID( "fsel" );
ref2.putProperty( id15, id16 );
desc4.putReference( id14, ref2 );
var id17 = charIDToTypeID( "T " );
var id18 = charIDToTypeID( "Ordn" );
var id19 = charIDToTypeID( "None" );
desc4.putEnumerated( id17, id18, id19 );
executeAction( id13, desc4, DialogModes.NO );

// =======================================================
var id20 = charIDToTypeID( "Cls " );
executeAction( id20, undefined, DialogModes.NO );
var id7 = charIDToTypeID( "slct" );
var desc3 = new ActionDescriptor();
var id8 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id9 = charIDToTypeID( "Lyr " );
ref2.putName( id9, "Auto_123" );
desc3.putReference( id8, ref2 );
var id10 = charIDToTypeID( "MkVs" );
desc3.putBoolean( id10, false );
executeAction( id7, desc3, DialogModes.NO );
var id21 = charIDToTypeID( "past" );
var desc5 = new ActionDescriptor();
var id22 = charIDToTypeID( "AntA" );
var id23 = charIDToTypeID( "Annt" );
var id24 = charIDToTypeID( "Anno" );
desc5.putEnumerated( id22, id23, id24 );
executeAction( id21, desc5, DialogModes.NO );
createSmartObject(app.activeDocument.activeLayer);
function createSmartObject(layer)
{
var idnewPlacedLayer = stringIDToTypeID( 'newPlacedLayer' );
executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
}
var oldPref = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var iLayer = doc.activeLayer;

layerDown ();

var mLayerB = doc.activeLayer.bounds;
doc.activeLayer = iLayer;
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));
iLayer.resize (scale*100,scale*100);
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);

clip ();

function clip(){
var idGrpL = charIDToTypeID( "GrpL" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref6 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref6.putEnumerated( idLyr, idOrdn, idTrgt );
desc7.putReference( idnull, ref6 );
executeAction( idGrpL, desc7, DialogModes.NO );
};

function layerDown(){
var idslct = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idBckw = charIDToTypeID( "Bckw" );
ref1.putEnumerated( idLyr, idOrdn, idBckw );
desc2.putReference( idnull, ref1 );
var idMkVs = charIDToTypeID( "MkVs" );
desc2.putBoolean( idMkVs, false );
var idLyrI = charIDToTypeID( "LyrI" );
var list1 = new ActionList();
list1.putInteger( 3 );
desc2.putList( idLyrI, list1 );
executeAction( idslct, desc2, DialogModes.NO );
};
var id3 = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var id4 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id5 = charIDToTypeID( "Lyr " );
var id6 = charIDToTypeID( "Ordn" );
var id7 = charIDToTypeID( "Bckw" );
ref1.putEnumerated( id5, id6, id7 );
desc2.putReference( id4, ref1 );
var id8 = charIDToTypeID( "MkVs" );
desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );


// =======================================================
var id9 = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var id10 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id11 = charIDToTypeID( "Lyr " );
var id12 = charIDToTypeID( "Ordn" );
var id13 = charIDToTypeID( "Trgt" );
ref2.putEnumerated( id11, id12, id13 );
desc3.putReference( id10, ref2 );
var id14 = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var id15 = charIDToTypeID( "Nm " );
desc4.putString( id15, "photoframe" );
var id16 = charIDToTypeID( "Lyr " );
desc3.putObject( id14, id16, desc4 );
executeAction( id9, desc3, DialogModes.NO );Screenshot 2022-10-03 131912.jpg

TOPICS
Actions and scripting
284
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
Community Expert ,
Oct 04, 2022 Oct 04, 2022

Moving thread to the Photoshop ecosystem forum from Using the Community

 

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
New Here ,
Oct 04, 2022 Oct 04, 2022

Open templet/ Sheet

Select layer

Rename Layer

Select Next Document

Copy Image

Close Image 

Paste

Convert to smart object

Fit to layer/ Frame

Same to many time repeat

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
New Here ,
Oct 05, 2022 Oct 05, 2022
LATEST

Screenshot 2022-10-03 131912 copy.jpg

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