Copy link to clipboard
Copied
Hi,
please could someone direct me a guide on how to apply the above.
i have a headland , so surrounded by water which makes sky replacement not effective. So, I'm looking to select the headland in the initial image (first) layer then apply it to subsequent Milky Way images, from which I'll convert to jpg and make a Timelapse. I've seen many like this so know it's possible and should be easy, but as much as I've tried searching, I'm coming up with everything except what I'm trying to do.
thanks
I have Photoshop, lightroom, lightroom classic and LRTimelapse (if the latter helps )
Copy link to clipboard
Copied
Have you isolated the change to its own layer, or is the change part of the original layer? I'm thinking that layer comps should be useful.
Providing a layered file with at least 3 layers would help, even at a reduced resolution. A screenshot of the layers panel with thumbnails is also useful to help understand the file structure.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The selection is independent of the layers... Apply the selection how?
Do you wish to copy the selected, previously adjusted "baked-in" pixels of the top layer to all lower layers, perhaps via copy/paste?
Do you wish to apply a recorded action that adjusts the pixels in one layer and run the selection and action to all other selected layers?
You can semi-automate this via an action, which would be run for each layer, then it would select the next layer, then you would rerun the action again as many times as required. Otherwise a script could loop over all layers automatically.
Copy link to clipboard
Copied
I'm looking to sort of "copy and paste" the selection, on the other layers replacing the equivalent selection, so as the stars move and sky gets even darker the headland stays the same level.
From that, save each layer as a jpg and create a timelapse video.
The Timelapse video I can do, it's the element of applying the selected headland/foreground to all the other layers where the sky has moved and foreground is darker.
my PS skills are fairly limited to a few regular things I do.
thanks again for replying
Copy link to clipboard
Copied
The following script presumes a foreground selection based on the top layer content, and that the lower layer content to be replaced is "pixel perfect" in alignment. The pixels inside the selection are copied using the Apply Image command to each of the lower layers, limited by the selection. This way the sky in each layer will vary, with the foreground being the same.
After running the script, you can then select all layers in the layers panel (Select > All Layers) and then right click on a layer and use Export As to export all the selected layers to JPEG or PNG for making your timelapse animation from the separate "frame" images.
/*
Apply selected pixels from top layer to lower layers.jsx
Stephen Marsh
v1.0 - 19th August 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-add-selected-lightened-foreground-to-multiple-night-sky-layers/td-p/15462698
*/
#target photoshop
app.activeDocument.suspendHistory("Apply selected pixels from top layer to lower layers...", "main()");
function main() {
if (!app.documents.length) {
alert("No document is open.");
return;
}
if (!hasSelection()) {
alert("This script requires a selection!");
return;
}
var doc = app.activeDocument;
var layers = doc.layers;
var originalVisibility = [];
// Save visibilities
for (var i = 0; i < layers.length; i++) {
originalVisibility[i] = layers[i].visible;
}
// Top layer reference
var topLayer = layers[0];
var topLayerName = topLayer.name;
doc.activeLayer = topLayer;
setOnlyVisible(layers, 0);
// Save selection if exists using a temp alpha channel
var selectionMade = true;
var tempChannelName = "_Temp-Alpha!";
var tempChannel;
try {
tempChannel = doc.channels.add();
tempChannel.name = tempChannelName;
doc.selection.store(tempChannel, SelectionType.REPLACE);
} catch (e) {
selectionMade = false; // no selection
}
// Loop through the lower layers
for (var i = 1; i < layers.length; i++) {
var target = layers[i];
doc.activeLayer = target;
setOnlyVisible(layers, i);
// Reload the selection if there was one
if (selectionMade) {
doc.selection.load(doc.channels.getByName(tempChannelName), SelectionType.REPLACE);
}
// Apply image
applyImageFromLayer();
}
// Restore the layer visibilities
for (var i = 0; i < layers.length; i++) {
layers[i].visible = originalVisibility[i];
}
// Cleanup temp channel
if (selectionMade) {
try {
var ch = doc.channels.getByName(tempChannelName);
ch.remove();
} catch (e) { }
}
alert("Script completed!");
///// FUNCTIONS /////
function hasSelection() {
var ref10 = new ActionReference();
ref10.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
ref10.putEnumerated(charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var docDesc = executeActionGet(ref10);
return docDesc.hasKey(stringIDToTypeID("selection"));
}
function setOnlyVisible(layerArray, indexToShow) {
for (var i = 0; i < layerArray.length; i++) {
layerArray[i].visible = (i === indexToShow);
}
}
function applyImageFromLayer() {
var idAppI = charIDToTypeID("AppI");
var desc6541 = new ActionDescriptor();
var idWith = charIDToTypeID("With");
var desc6542 = new ActionDescriptor();
var idT = charIDToTypeID("T ");
var ref2091 = new ActionReference();
var idChnl = charIDToTypeID("Chnl");
var idRGB = charIDToTypeID("RGB ");
ref2091.putEnumerated(idChnl, idChnl, idRGB);
var idLyr = charIDToTypeID("Lyr ");
ref2091.putName(idLyr, topLayerName);
desc6542.putReference(idT, ref2091);
var idClcl = charIDToTypeID("Clcl");
desc6541.putObject(idWith, idClcl, desc6542);
executeAction(idAppI, desc6541, DialogModes.NO);
}
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Find more inspiration, events, and resources on the new Adobe Community
Explore Now