Skip to main content
Inspiring
June 17, 2020
Answered

Shift+Ctrl+Alt+E Stamp Layer script equivalent

  • June 17, 2020
  • 1 reply
  • 1562 views

A stamp layer is easy via Shift+Ctrl+Alt+E but is pages long in scrptlistener, is there an easy way to scipt this?

This topic has been closed for replies.
Correct answer Kukurykus

Combining the answers and adding a small amount I get this function, it creates the new layer as required, for the stamp layer it does name it as BLUR but for the background only copy it renames the background layer as BLUR and the new layer is Background copy, so I need to get the new layer in focus before the rename action

function stampLayer(){
    if (activeDocument.layers.length > 1){
        var adStampLayer = new ActionDescriptor();
        adStampLayer.putBoolean( charIDToTypeID( "Dplc" ), true );
	executeAction( charIDToTypeID( "MrgV" ), adStampLayer, DialogModes.NO ); }
	
	if (!((lrs = (aD = activeDocument).layers).length - 1) && (bG = lrs[0]).isBackgroundLayer) bG.duplicate();
	
	var docRef = activeDocument
	docRef.activeLayer.name = "BLUR";
	docRef.activeLayer.applyGaussianBlur(20);
    
};

If you want duplication was selected, use this code after bG.duplicate() (before semicolon):

 

, aD.activeHistoryState = (sH = aD.historyStates)[sH.length - 1]

 

1 reply

Inspiring
June 17, 2020

You could try this...

 

 

function stampLayer(){
    var adStampLayer = new ActionDescriptor();
    adStampLayer.putBoolean( charIDToTypeID( "Dplc" ), true );
    executeAction( charIDToTypeID( "MrgV" ), adStampLayer, DialogModes.NO );
};

 

Set the Dplc to false to emulate "Flatten Image", though you can do that in one line by removing adStampLayer and replace it by undefined in executeAction

 

Inspiring
June 17, 2020

many thanks unfortunately i get a message that mrge visible not available in this version of photoshop where there is only 1 layer

Inspiring
June 18, 2020

A bit late to the party... I'm a beginner, so take from this what you will... Here is a basic conditional check for a background or layered file.

 

 

if (app.activeDocument.activeLayer.isBackgroundLayer)
	{
	alert("Flattened");
	}
else
	{
	alert("Layered");
	}

 

 

That being said, I'm not sure why you wish to put in this check?

 

The code being discussed will add a new layer, then merge visible layers with duplicate.

 

In my limited testing, the code works the same whether or not the image is flattened or layered. Am I missing something?

 

P.S. I would have offered this code for the new layer/merge visible with dupe:

 

app.activeDocument.artLayers.add();
var mrgVis = charIDToTypeID("MrgV");
var actDesc = new ActionDescriptor();
var withDupe = charIDToTypeID("Dplc");
actDesc.putBoolean(withDupe, true);
executeAction(mrgVis, actDesc, DialogModes.NO);

 

 

 


yes, the original answer I was given threw an error on a single layer document, hence the original need for a check