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

How to add selected lightened foreground to multiple night sky layers

New Here ,
Aug 17, 2025 Aug 17, 2025

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 ) 

TOPICS
Windows
244
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 ,
Aug 17, 2025 Aug 17, 2025

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.

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 ,
Aug 19, 2025 Aug 19, 2025

Thanks for the reply. I think my original post probably wasn't as clear as it should have been. (I blame age) 

 

I've attached am image. 
im looking to apply the selection (though it would be selected accurately) to the other layers 

 

hope this helps 

simon 

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
Community Expert ,
Aug 19, 2025 Aug 19, 2025

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.

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 ,
Aug 19, 2025 Aug 19, 2025

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 

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
Community Expert ,
Aug 19, 2025 Aug 19, 2025
LATEST

@Chewie1965 

 

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);
    }
}

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

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