Hello, I’m a beginner trying to make a simple UXP plugin that generates a new layer with blended pixels of two pre-selected layers. I am trying to figure out how to find corresponding pixels because each layer has a different size and position. Any tips or links to other posts would be appreciated.
As in Layer > Merge Down but pressing the Option key to create a new layer?
I don’t think Layer.merge()
can do the merge on a new layer, you’ve got to resort to good, old, ugly BatchPlay:
const photoshop = require('photoshop');
const batchPlay = photoshop.action.batchPlay;
const executeAsModal = photoshop.core.executeAsModal;
let res = await executeAsModal(async () => {
let r = await batchPlay([
{
_obj: "mergeLayersNew",
duplicate: true
}
], {})
console.log(r)
}, { commandName: "baa" })
Of course commandName
can also bee
, or boo
, it’s your pick
Doc on BatchPlay and executeAsModal.
I also was thinking of this approach, but this merges all visible layers, not only selected ones. I guess to merge only selected, you’d need to hide all other layers, do the merge, and then make visible those, that were hidden
I don’t think so, unless I’ve misunderstood the initial question
If 2 layers are active, the provided code merges them only in a new layer:
Leaving the topmost (in the above example) out.
Ah, I was thinking about mergeVisible
instead of mergeLayersNew
. My bad