Skip to main content
Inspiring
October 7, 2022
Question

Layers - Creating Layers

  • October 7, 2022
  • 4 replies
  • 1142 views
I have two separate folders on my desktop
One contains 50 photos all in the JPEG format
The other contains 50 photos in the PSD format
 
I have been embedding photos one at a time using FILE - PLACE EMBEDDED - PLACE - SAVE.
in order to establish each photo as a LAYER.
 
Is there a way to transfer or copy all 50 photos into photoshop all at once and at the same time, create
a layer for each individutal photo?  

4 replies

Stephen Marsh
Community Expert
January 10, 2023

I have added a third version of the Stacker script that doesn't use smart objects:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/combining-tiffs/m-p/13475955

 

Stephen Marsh
Community Expert
October 8, 2022

Yet another option, a three-step approach, is to use the default script that ships with Photoshop:

 

File > Scripts > Load Files Into Stack (don't tick the smart object box)... Then, use Select > All Layers.

 

Finally, use one of the following custom scripts to convert all selected layers into an individual smart object layer:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-that-converts-layers-to-separate-smart-objects/m-p/11966325

 

Or this one:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/smart-objects-in-separate-layers/td-p/11137197

Stephen Marsh
Community Expert
October 7, 2022

@JoelGlobal 

 

I already have a script made for stacking a folder of files into separate layers as linked smart objects. Here it is:

 

/*
Stacker - Place Linked.jsx
Stephen Marsh, v1.0
*/

#target photoshop

if (app.documents.length === 0) {
    (function () {
        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        var origUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var inputFolder = Folder.selectDialog('Please select the input folder:');
        if (inputFolder === null) {
            app.beep();
            return;
        }

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb|gif)$/i);
        // inputFiles.sort().reverse;
        inputFiles.sort();

        app.displayDialogs = DialogModes.NO;

        var baseDoc = open(inputFiles[0]);
        var baseDoc = activeDocument;
        baseDoc.duplicate("Stacker", false);
        baseDoc.close(SaveOptions.DONOTSAVECHANGES);

        for (var i = 0; i < inputFiles.length; i++) {
            placeFile(new File(inputFiles[i]), true, 0, 0);
            // Remove the filename extension from the layer name
            activeDocument.activeLayer.name = inputFiles[i].name.replace(/\.[^\.]+$/, '');
            //align2SelectAll('AdCH');
            //align2SelectAll('AdCV');
        }

        activeDocument.activeLayer = activeDocument.backgroundLayer;
        activeDocument.activeLayer.remove();

        //app.runMenuItem(stringIDToTypeID("selectAllLayers"));
        //reverseLayerStack();
        app.beep();
        alert(inputFiles.length + ' files stacked!');
        app.displayDialogs = savedDisplayDialogs;
        app.preferences.rulerUnits = origUnits;


        // Functions

        function placeFile(null2, linked, horizontal, vertical) {
            var s2t = function (s) {
                return app.stringIDToTypeID(s);
            };
            var AD = new ActionDescriptor();
            AD.putInteger(s2t("ID"), 1);
            AD.putPath(s2t("null"), null2);
            AD.putBoolean(s2t("linked"), linked); // false for embedded
            AD.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSAverage"));
            AD.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
            AD.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
            AD.putObject(s2t("offset"), s2t("offset"), AD);
            executeAction(s2t("placeEvent"), AD, DialogModes.NO);
        }

        function reverseLayerStack() {
            var idreverse = stringIDToTypeID("reverse");
            var desc4653 = new ActionDescriptor();
            var idnull = stringIDToTypeID("null");
            var ref2335 = new ActionReference();
            var idlayer = stringIDToTypeID("layer");
            var idordinal = stringIDToTypeID("ordinal");
            var idtargetEnum = stringIDToTypeID("targetEnum");
            ref2335.putEnumerated(idlayer, idordinal, idtargetEnum);
            desc4653.putReference(idnull, ref2335);
            executeAction(idreverse, desc4653, DialogModes.NO);
        }

        function align2SelectAll(method) {
            /*
            AdLf = Align Left
            AdRg = Align Right
            AdCH = Align Centre Horizontal
            AdTp = Align Top
            AdBt = Align Bottom
            AdCV = Align Centre Vertical
            */
            app.activeDocument.selection.selectAll();
            var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
            desc.putReference(charIDToTypeID("null"), ref);
            desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
            try {
                executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
            } catch (e) {}
            app.activeDocument.selection.deselect();
        }
    })();

} else {
    alert('Please close all open files before running this script...');
}

 

I'll update it to create embedded smart object layers and post the update in a separate reply.

 

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

 

Stephen Marsh
Community Expert
October 7, 2022

@JoelGlobal – Here is the updated script for embedding.

 

Although I only needed to change a single entry of true to false, I decided to post the entire script rather than provide instructions for changing the previous script (there was a hint in the code comments).

 

There are "latent" options in the script to align all of the layers (top left, centre etc) or to reverse the layer order. The script removes the filename extension, so original-file.jpg would have a layer name of original-file – it is easy enough to change this if you prefer to have the extension in the layer as a reference.

 

/*
Stacker - Place Embedded.jsx
Stephen Marsh, v1.0
https://community.adobe.com/t5/photoshop-ecosystem-discussions/layers-creating-layers/td-p/13252109
*/

#target photoshop

if (app.documents.length === 0) {
    (function () {
        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        var origUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var inputFolder = Folder.selectDialog('Please select the input folder:');
        if (inputFolder === null) {
            app.beep();
            return;
        }

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb|gif)$/i);
        // inputFiles.sort().reverse;
        inputFiles.sort();

        app.displayDialogs = DialogModes.NO;

        var baseDoc = open(inputFiles[0]);
        var baseDoc = activeDocument;
        baseDoc.duplicate("Stacker", false);
        baseDoc.close(SaveOptions.DONOTSAVECHANGES);

        for (var i = 0; i < inputFiles.length; i++) {
            placeFile(new File(inputFiles[i]), false, 0, 0);
            // Remove the filename extension from the layer name
            activeDocument.activeLayer.name = inputFiles[i].name.replace(/\.[^\.]+$/, '');
            //align2SelectAll('AdCH');
            //align2SelectAll('AdCV');
        }

        activeDocument.activeLayer = activeDocument.backgroundLayer;
        activeDocument.activeLayer.remove();

        //app.runMenuItem(stringIDToTypeID("selectAllLayers"));
        //reverseLayerStack();
        app.beep();
        alert(inputFiles.length + ' files stacked!');
        app.displayDialogs = savedDisplayDialogs;
        app.preferences.rulerUnits = origUnits;


        // Functions

        function placeFile(null2, linked, horizontal, vertical) {
            var s2t = function (s) {
                return app.stringIDToTypeID(s);
            };
            var AD = new ActionDescriptor();
            AD.putInteger(s2t("ID"), 1);
            AD.putPath(s2t("null"), null2);
            AD.putBoolean(s2t("linked"), linked); // false for embedded
            AD.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSAverage"));
            AD.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
            AD.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
            AD.putObject(s2t("offset"), s2t("offset"), AD);
            executeAction(s2t("placeEvent"), AD, DialogModes.NO);
        }

        function reverseLayerStack() {
            var idreverse = stringIDToTypeID("reverse");
            var desc4653 = new ActionDescriptor();
            var idnull = stringIDToTypeID("null");
            var ref2335 = new ActionReference();
            var idlayer = stringIDToTypeID("layer");
            var idordinal = stringIDToTypeID("ordinal");
            var idtargetEnum = stringIDToTypeID("targetEnum");
            ref2335.putEnumerated(idlayer, idordinal, idtargetEnum);
            desc4653.putReference(idnull, ref2335);
            executeAction(idreverse, desc4653, DialogModes.NO);
        }

        function align2SelectAll(method) {
            /*
            AdLf = Align Left
            AdRg = Align Right
            AdCH = Align Centre Horizontal
            AdTp = Align Top
            AdBt = Align Bottom
            AdCV = Align Centre Vertical
            */
            app.activeDocument.selection.selectAll();
            var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
            desc.putReference(charIDToTypeID("null"), ref);
            desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
            try {
                executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
            } catch (e) {}
            app.activeDocument.selection.deselect();
        }
    })();

} else {
    alert('Please close all open files before running this script...');
}

 

 

Inspiring
October 8, 2022

So sorry to say I would not know what to do with a srcipt.  Iwas looking for the "clicks" within theprogram that would accomplish this.

Chuck Uebele
Community Expert
October 7, 2022

You would need to Adobe this with a script. Are you adding all 50 jpgs to each 50 psd files, or is just one jpg going in each pad file? There have been some other post about doing this.

Inspiring
October 8, 2022

50 different JPEGs and 50 different PSDs.  I want to send them from my desktop into Photoshop and simulateously creating a layer for each photo.  As mentioned  earlier, I am doing this one at a time and it is a bit tedious.  Thanks