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

help loading images into layers by filename

Community Beginner ,
May 03, 2023 May 03, 2023

Copy link to clipboard

Copied

Hello, I'm having an issue that I'm unable to find help with in the forum, if the answer already esists I apologize.

 

I have a series of photograohs that were worked on by a professional retoucher and the original images in lightroom. To keep my lightroom catalog clean I am now chosing Edit in Photoshop in lightroom to open each image as a psd and then dragging the cooresponding jpeg to the top as a new layer and resaving to reflect changes in lightroom.  While this does work, I have dozens of images and it's taking forever. 

 

is there a script to automatically align an external file with a currently open file in photoshop that could save me some time?

 

 

thank you in advance

-Josh

TOPICS
Actions and scripting , macOS

Views

3.1K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , May 07, 2023 May 07, 2023

Don't have any unsaved files open when running this script.

 

If you are using PSD, I have simplified the code to save in the current file format, by simply closing/saving the edited file. As the PSD options are no longer set, you might have to set maximise compatibility depending on your preferences. If TIFF you may or may not need to select save options.

 

Does this 1.1 version work without locking up? It obviously doesn't lock up for me, but I don't use Lr and I'm not sure of the issue with r

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 03, 2023 May 03, 2023

Copy link to clipboard

Copied

I must have forgotten my jellyfish pills. I can't picture what you're trying to do.

 

OPTION 1:  Photoshop can make a contact sheet.

Go to File > Automate > Contact Sheet II > load images and sort by file name.

 

OPTION 2: Create a single file with multiple images stacked in layers.

File > Scripts > Load files into Stack. 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

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 Beginner ,
May 03, 2023 May 03, 2023

Copy link to clipboard

Copied

thank you for the reply, unfortunately neither of those 2 options are what I'm looking for.

 

I guess to try and make it more clear:

I have several images named IMG001.raf, Img002.raf etc and several coorisponding images named IMG001_retouched.jpg, IMG002_retouched.jpg etc.

 

I'm looking for a way to match the retouched files and layer them over the originals automatically, rather than one at a time by hand as I have been doing for days now.

Votes

Translate

Translate

Report

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 ,
May 04, 2023 May 04, 2023

Copy link to clipboard

Copied

@joshakatz – A script could possibly help here... As these are raw files, they will open into ACR first, so to successfully layer them it would be best to batch save the raw files as TIFF or PSD first, then use a script to match up the files. One would then either have the input files in a single folder, or in two separate input folders for the script to process.

 

Can you explain step by step your workflow with the .raf files and the .jpg files?

Votes

Translate

Translate

Report

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 Beginner ,
May 04, 2023 May 04, 2023

Copy link to clipboard

Copied

my workflow is as follows:

 

the images are all cataloged in lightroom where I do basic color edits.

I then export a copy for my retoucher to work on.

he then sends back a folder of images (IMG001_retouched, IMG002_retouched etc)

I send my original files from lightroom to photoshop (which bypasses ACR btw)

I then take the retouched file and layer it over the original in photoshop.

close and save the image which then shows the final edited psd in lightroom for easy cataloging.

 

I hope that makes some sense

 

Votes

Translate

Translate

Report

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 ,
May 04, 2023 May 04, 2023

Copy link to clipboard

Copied


@joshakatz wrote:

 

I send my original files from lightroom to photoshop (which bypasses ACR btw)

 

Thanks, I don't use Lr, therefore I need more info to help automate the process.

 

So does this mean that you have multiple raw files which are now rendered and open in Ps?

 

Then you wish to automatically layer the retouched JPEG over the matching file from Lr?

 

Then save as PSD? Is the file opened from Lr saved to drive as a PSD or it it simply sent from Lr to Ps as an unsaved file?

 

Ideally there are no open files in Ps, just files ready for stacking based on alphabetical sorting filenames.

Votes

Translate

Translate

Report

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 Beginner ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

yes, I have multiple raw files rendered and open in photoshop and I would like o automatically layer the retouched JPEG over the matching file from Lr and then save as PSD.

 

That's my current workflow and the one that keeps my Lr catalog in order as best I know.

 

 

Votes

Translate

Translate

Report

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 ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

quote

yes, I have multiple raw files rendered and open in photoshop

 

OK, but are they saved to file on the drive, or are they unsaved files? What if you do a save as, does it point to the file and location or is the file unsaved and only open in memory?

 

 

That's my current workflow and the one that keeps my Lr catalog in order as best I know.

 

By @joshakatz

 

So is it possible to access the files on the drive, is the path to the files known or can it be found?

 

Votes

Translate

Translate

Report

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 Beginner ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

the files are saved on my hard drive and the path is known

Votes

Translate

Translate

Report

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 ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

quote

the files are saved on my hard drive and the path is known


By @joshakatz

 

OK, are the files rendered from Lr PSD files?

 

So with no files open in Photoshop, if you manually open both the (PSD?) file from Lr and the retouched JPEG file, then layer and JPEG over the previously saved file from Lr and then close/save, is that it? Everything then works as needed?

 

I envision you would have a folder of the rendered raw files, and a matching folder of the retouched JPEG files (same file count in both folders), then a script would batch process and layer the images. You would select both folders via a folder selection window. Would that be workable?

 

Or do you need more flexibility, the two folders may or may not contain the same amount of images?

 

Or perhaps there is one folder?

 

Or with the rendered files open in Photoshop, would it be better to just point to the folder of retouched files and then the script would get the retouched file corresponding to the name of the current open file and layer it? Not batching, just one ad-hoc file at a time?

 

Votes

Translate

Translate

Report

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 Beginner ,
May 05, 2023 May 05, 2023

Copy link to clipboard

Copied

 

Or with the rendered files open in Photoshop, would it be better to just point to the folder of retouched files and then the script would get the retouched file corresponding to the name of the current open file and layer it? Not batching, just one ad-hoc file at a time?

 

 

With this option would it be able to handle multiple files at once? Batch processing is what I'm looking for.

If not, pulling from two folders is absolutley ok with me. The folders would have different amounts of files though.

 

BTW I sincerely appreciate your help and time on this.

Votes

Translate

Translate

Report

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 ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

@joshakatz 

 

Try the following script, it is designed to work with open PSD files (you didn't answer my question if they were PSD).

 

It is presumed and required that all open PSD files have been previously saved (so that there is a backing path to the file on the drive), otherwise, the script may be interrupted. It is also presumed that the JPEG file name matches the PSD with the addition of "_retouched.jpg". If the path to the retouched JPEG folder is always the same, this could be coded into the script rather than being asked to select the folder.

 

/*
Layer & Save Matching Retouched JPEG over All Open PSD Files.jsx
v1.0 - 7th May 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-loading-images-into-layers-by-filename/td-p/13769691
Notes:
All open files should have been previously saved, unsaved files may interrupt the batch processing
JPEG file names must match the open PSD name, with the addition of "_retouched.jpg" at the end of the doc name
*/

#target photoshop

if (app.documents.length > 0) {
    (function () {
        var jpgFolder = Folder.selectDialog('Please select the retouched JPEG folder:');
        if (jpgFolder === null) return;
        var psdOptions = new PhotoshopSaveOptions();
        psdOptions.embedColorProfile = true;
        psdOptions.alphaChannels = true;
        psdOptions.layers = true;
        psdOptions.spotColors = true;
        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        while (app.documents.length > 0) {
            if (activeDocument.path) {
                var psdName = activeDocument.name.replace(/\.[^\.]+$/, '');
                var jpgName = psdName + "_retouched.jpg";
                var jpgFile = jpgFolder + '/' + jpgName;
                placeFile(File(jpgFile), 100);
                activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
                activeDocument.saveAs(new File(activeDocument.fullName), psdOptions);
                activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            } else {
                alert("The file has never been saved!");
            }
        }
        app.displayDialogs = savedDisplayDialogs;
        app.beep();
    })();
}
else {
    alert('One or more previously saved docs must be open to use this script!');
}

function placeFile(file, scale) {
    try {
        var idPlc = charIDToTypeID("Plc ");
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        desc2.putPath(idnull, new File(file));
        var idFTcs = charIDToTypeID("FTcs");
        var idQCSt = charIDToTypeID("QCSt");
        var idQcsa = charIDToTypeID("Qcsa");
        desc2.putEnumerated(idFTcs, idQCSt, idQcsa);
        var idOfst = charIDToTypeID("Ofst");
        var desc3 = new ActionDescriptor();
        var idHrzn = charIDToTypeID("Hrzn");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idHrzn, idPxl, 0.000000);
        var idVrtc = charIDToTypeID("Vrtc");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idVrtc, idPxl, 0.000000);
        var idOfst = charIDToTypeID("Ofst");
        desc2.putObject(idOfst, idOfst, desc3);
        var idWdth = charIDToTypeID("Wdth");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idWdth, idPrc, scale);
        var idHght = charIDToTypeID("Hght");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idHght, idPrc, scale);
        var idAntA = charIDToTypeID("AntA");
        desc2.putBoolean(idAntA, true);
        executeAction(idPlc, desc2, DialogModes.NO);
    } catch (e) { }
}

 

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

 

Votes

Translate

Translate

Report

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 Beginner ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

the script worked for one image and then. the progress bar got stuck. 

 

so it's almost working. I think the issue is the files are not yet saved as PSDs, sorry, I thought I replied to that before. 

 

Is it possible to do this with .raf files instead of PSDs?

 

Votes

Translate

Translate

Report

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 ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

You previously wrote:

 

"I send my original files from lightroom to photoshop (which bypasses ACR btw)"

 

and

 

"the files are saved on my hard drive and the path is known"

 

Perhaps it would help if you provided detailed, factual information that actually aligns with what is taking place.

Votes

Translate

Translate

Report

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 Beginner ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

That is all factual information but I'm sorry if I'm unable to communicate this more clearly. I'm doing my best here and I'm admittedly out of my depth but im doing my best to communicate with you on this.  
I appreciate your help and the script you wrote is nearly exactly what I needed.  If you are no longer able to or don't have the time to continue I understand.  

Votes

Translate

Translate

Report

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 ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

It is not possible for Ps to open a raw file, they have to be rendered into Photoshop through ACR.

 

As you are using Lr and sending to Photoshop, the issue would appear to be there:

 

* What file format? PSD, TIFF, What???

 

* Where are the files saved on drive? If you manually make an edit, close/save, does it work?

 

The files are either saved to drive before opening in Ps – or they are sent into Ps from Lr as an unsaved file, which is it?

Votes

Translate

Translate

Report

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 Beginner ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

I just saved a group of images as psds as a test and the progress bar gets stuck again during "Writing Photoshop Format"

 

Votes

Translate

Translate

Report

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 ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

Don't have any unsaved files open when running this script.

 

If you are using PSD, I have simplified the code to save in the current file format, by simply closing/saving the edited file. As the PSD options are no longer set, you might have to set maximise compatibility depending on your preferences. If TIFF you may or may not need to select save options.

 

Does this 1.1 version work without locking up? It obviously doesn't lock up for me, but I don't use Lr and I'm not sure of the issue with resaving back to a file that is in your Lr library/catalogue.

 

/*
Layer & Save Matching Retouched JPEG over All Open PSD Files.jsx
v1.1 - 7th May 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/help-loading-images-into-layers-by-filename/td-p/13769691
Notes:
All open files should have been previously saved, unsaved files may interrupt the batch processing
JPEG file names must match the open PSD name, with the addition of "_retouched.jpg" at the end of the doc name
*/

#target photoshop

if (app.documents.length > 0) {
    (function () {
        var jpgFolder = Folder.selectDialog('Please select the retouched JPEG folder:');
        if (jpgFolder === null) return;
        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        while (app.documents.length > 0) {
                var psdName = activeDocument.name.replace(/\.[^\.]+$/, '');
                var jpgName = psdName + "_retouched.jpg";
                var jpgFile = jpgFolder + '/' + jpgName;
                placeFile(File(jpgFile), 100);
                activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
                activeDocument.close(SaveOptions.SAVECHANGES);
        }
        app.displayDialogs = savedDisplayDialogs;
        app.beep();
    })();
}
else {
    alert('One or more previously saved docs must be open to use this script!');
}

function placeFile(file, scale) {
    try {
        var idPlc = charIDToTypeID("Plc ");
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        desc2.putPath(idnull, new File(file));
        var idFTcs = charIDToTypeID("FTcs");
        var idQCSt = charIDToTypeID("QCSt");
        var idQcsa = charIDToTypeID("Qcsa");
        desc2.putEnumerated(idFTcs, idQCSt, idQcsa);
        var idOfst = charIDToTypeID("Ofst");
        var desc3 = new ActionDescriptor();
        var idHrzn = charIDToTypeID("Hrzn");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idHrzn, idPxl, 0.000000);
        var idVrtc = charIDToTypeID("Vrtc");
        var idPxl = charIDToTypeID("#Pxl");
        desc3.putUnitDouble(idVrtc, idPxl, 0.000000);
        var idOfst = charIDToTypeID("Ofst");
        desc2.putObject(idOfst, idOfst, desc3);
        var idWdth = charIDToTypeID("Wdth");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idWdth, idPrc, scale);
        var idHght = charIDToTypeID("Hght");
        var idPrc = charIDToTypeID("#Prc");
        desc2.putUnitDouble(idHght, idPrc, scale);
        var idAntA = charIDToTypeID("AntA");
        desc2.putBoolean(idAntA, true);
        executeAction(idPlc, desc2, DialogModes.NO);
    } catch (e) { }
}

 

 

Votes

Translate

Translate

Report

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 Beginner ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

this new script works well when using tiff export from Lightroom instead of psd export. 

 

thank you, I think we got it!

 

I sincerely appreciate your help and time on this, I know it wasn't an easy one.

Votes

Translate

Translate

Report

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 ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

LATEST

Glad it works for you! As I don't use Lr, I am very much dependent on the info provided as I am flying blind.

Votes

Translate

Translate

Report

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