Highlighted

Open photos with same filename as layers

Community Beginner ,
Oct 18, 2020

Copy link to clipboard

Copied

Hi.

I'm looking for a method to batch combine two photos with for example the same filename to layers in one tif file.

Example:

DSC0001.tif = Layer 1

DSC0001.jpg = Layer 2

I do process photos twice in different ways and now I manually open photo by photo, import different version and do 50% opacity :(

Please help 🙂

 

Sorry for my bad English.

Adobe Community Professional
Correct answer by Stephen_A_Marsh | Adobe Community Professional

I made a quick edit to a script that I had previously hacked together. A single source folder is selected and the script will then process pairs of files, stacking one over the other at 50% opacity, then save out a JPEG into a newly named folder within the source folder. 

 

It is assumed that all file pairs have correct alphabetical pair names for sorting and that the total count of all files is divisible by 2.

 

 

#target photoshop

var restoreDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

main();

function main() {
    inputFolder = Folder.selectDialog("Please select the folder with Files to process");
    if (inputFolder === null) return;
    var newPath = Folder(decodeURI(inputFolder + "/Combined")); // Create sub-dir 
    if (!newPath.exists) newPath.create();
    var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd)$/i); // Limit file format input
    fileList.sort(); // Force alpha-numeric list sort
    while (fileList.length) {
        for (var a = 0; a < 2; a++) { // Digit 2 for two files
            try {
                app.open(fileList.pop());
            } catch (e) { }
        }
        processFiles();
    }

    alert("Done!");

    function processFiles() {
        try {
            var Name = app.documents[0].name.replace(/\.[^\.]+$/, ''); // Remove file extension

            app.activeDocument = documents[1];
            app.activeDocument.activeLayer.duplicate(documents[0]);
            app.activeDocument = documents[0];

            var doc = app.activeDocument;
            doc.activeLayer.opacity = 50.0; // Layer opacity
            doc.activeLayer.blendMode = BlendMode.NORMAL; // Blend mode

            app.displayDialogs = restoreDialogMode;

        } catch (e) { }
        var saveFile = File(newPath + "/" + Name + "_Combined" + ".tif");
        saveTIFF(saveFile);
        while (app.documents.length) {
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }
    }
}

function saveTIFF(saveFile) {
    tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.embedColorProfile = true;
    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    tiffSaveOptions.transparency = true;
    tiffSaveOptions.layers = true;
    tiffSaveOptions.layerCompression = LayerCompression.ZIP;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.annotations = true;
    tiffSaveOptions.spotColors = true;
    tiffSaveOptions.saveImagePyramid = false;
    // NONE | JPEG | TIFFLZW | TIFFZIP
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    app.activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}

 

 

The script can be modified to save out a TIFF if it otherwise performs as required... What TIFF save options are needed?

 

EDIT: I have updated the code with TIFF save options rather than JPEG.

 

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

 

TOPICS
Actions and scripting, How to

Views

173

Likes

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

Open photos with same filename as layers

Community Beginner ,
Oct 18, 2020

Copy link to clipboard

Copied

Hi.

I'm looking for a method to batch combine two photos with for example the same filename to layers in one tif file.

Example:

DSC0001.tif = Layer 1

DSC0001.jpg = Layer 2

I do process photos twice in different ways and now I manually open photo by photo, import different version and do 50% opacity :(

Please help 🙂

 

Sorry for my bad English.

Adobe Community Professional
Correct answer by Stephen_A_Marsh | Adobe Community Professional

I made a quick edit to a script that I had previously hacked together. A single source folder is selected and the script will then process pairs of files, stacking one over the other at 50% opacity, then save out a JPEG into a newly named folder within the source folder. 

 

It is assumed that all file pairs have correct alphabetical pair names for sorting and that the total count of all files is divisible by 2.

 

 

#target photoshop

var restoreDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

main();

function main() {
    inputFolder = Folder.selectDialog("Please select the folder with Files to process");
    if (inputFolder === null) return;
    var newPath = Folder(decodeURI(inputFolder + "/Combined")); // Create sub-dir 
    if (!newPath.exists) newPath.create();
    var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd)$/i); // Limit file format input
    fileList.sort(); // Force alpha-numeric list sort
    while (fileList.length) {
        for (var a = 0; a < 2; a++) { // Digit 2 for two files
            try {
                app.open(fileList.pop());
            } catch (e) { }
        }
        processFiles();
    }

    alert("Done!");

    function processFiles() {
        try {
            var Name = app.documents[0].name.replace(/\.[^\.]+$/, ''); // Remove file extension

            app.activeDocument = documents[1];
            app.activeDocument.activeLayer.duplicate(documents[0]);
            app.activeDocument = documents[0];

            var doc = app.activeDocument;
            doc.activeLayer.opacity = 50.0; // Layer opacity
            doc.activeLayer.blendMode = BlendMode.NORMAL; // Blend mode

            app.displayDialogs = restoreDialogMode;

        } catch (e) { }
        var saveFile = File(newPath + "/" + Name + "_Combined" + ".tif");
        saveTIFF(saveFile);
        while (app.documents.length) {
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }
    }
}

function saveTIFF(saveFile) {
    tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.embedColorProfile = true;
    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    tiffSaveOptions.transparency = true;
    tiffSaveOptions.layers = true;
    tiffSaveOptions.layerCompression = LayerCompression.ZIP;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.annotations = true;
    tiffSaveOptions.spotColors = true;
    tiffSaveOptions.saveImagePyramid = false;
    // NONE | JPEG | TIFFLZW | TIFFZIP
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    app.activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}

 

 

The script can be modified to save out a TIFF if it otherwise performs as required... What TIFF save options are needed?

 

EDIT: I have updated the code with TIFF save options rather than JPEG.

 

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

 

TOPICS
Actions and scripting, How to

Views

174

Likes

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
Oct 18, 2020 1
Most Valuable Participant ,
Oct 18, 2020

Copy link to clipboard

Copied

The "BatchMockupTemplates.jsx"  in my Free Photoshop Photo Collage and Mockup Toolkit  will do that but save the combines images as a jpeg and optionally as a Layered PSD. There is no option to save layered Tiff files.  All you need do is create a mockup template for how you want to combine the two images, and have the images in two folder and point the script to the templates, images collection and output destination.

image.png

JJMack

Likes

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
Reply
Loading...
Oct 18, 2020 4
Most Valuable Participant ,
Oct 19, 2020

Copy link to clipboard

Copied

To create the mockup template all you need to do is open a net document that has a canvas size and print resolution as your two image files.  Place in one Tif image to cover the canvas. then place in one jpeg to covet the first image. Set the layers opacity to 50%.  and save the document as your Mockup PSD template. 

 

Put the mock in a job folder sub folder Mockup.  Create a Replacement Image collection folder in the job folder and in the collection folder in a sub folder obj0 and sub folder obj1. Store you jpeg files in folder objo and store your tiff files in obj1. The run the script do not forget to check save psd file

image.png

 

You could add additional mockup templates into the mockup folder where you would mask half the top Smart object layer to let the bottom object show in the mask off half.  An additional one where the canvas is twice as wide and you place the images in side by side the script would populate all three templates in a single run 

 

JJMack

Likes

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
Reply
Loading...
Oct 19, 2020 1
Adobe Community Professional ,
Oct 19, 2020

Copy link to clipboard

Copied

JJMack's scripts are a good place to start.

 

I adapted one of his scripts for this task in another forum topic:

 

https://community.adobe.com/t5/photoshop/batch-automating-sequences-of-images/m-p/10619866

https://github.com/MarshySwamp/Layer-Stack-N-Number-of-Files-Filename-as-Top-Layer

 

Likes

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
Reply
Loading...
Oct 19, 2020 0
Adobe Community Professional ,
Oct 19, 2020

Copy link to clipboard

Copied

I made a quick edit to a script that I had previously hacked together. A single source folder is selected and the script will then process pairs of files, stacking one over the other at 50% opacity, then save out a JPEG into a newly named folder within the source folder. 

 

It is assumed that all file pairs have correct alphabetical pair names for sorting and that the total count of all files is divisible by 2.

 

 

#target photoshop

var restoreDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

main();

function main() {
    inputFolder = Folder.selectDialog("Please select the folder with Files to process");
    if (inputFolder === null) return;
    var newPath = Folder(decodeURI(inputFolder + "/Combined")); // Create sub-dir 
    if (!newPath.exists) newPath.create();
    var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd)$/i); // Limit file format input
    fileList.sort(); // Force alpha-numeric list sort
    while (fileList.length) {
        for (var a = 0; a < 2; a++) { // Digit 2 for two files
            try {
                app.open(fileList.pop());
            } catch (e) { }
        }
        processFiles();
    }

    alert("Done!");

    function processFiles() {
        try {
            var Name = app.documents[0].name.replace(/\.[^\.]+$/, ''); // Remove file extension

            app.activeDocument = documents[1];
            app.activeDocument.activeLayer.duplicate(documents[0]);
            app.activeDocument = documents[0];

            var doc = app.activeDocument;
            doc.activeLayer.opacity = 50.0; // Layer opacity
            doc.activeLayer.blendMode = BlendMode.NORMAL; // Blend mode

            app.displayDialogs = restoreDialogMode;

        } catch (e) { }
        var saveFile = File(newPath + "/" + Name + "_Combined" + ".tif");
        saveTIFF(saveFile);
        while (app.documents.length) {
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }
    }
}

function saveTIFF(saveFile) {
    tiffSaveOptions = new TiffSaveOptions();
    tiffSaveOptions.embedColorProfile = true;
    tiffSaveOptions.byteOrder = ByteOrder.IBM;
    tiffSaveOptions.transparency = true;
    tiffSaveOptions.layers = true;
    tiffSaveOptions.layerCompression = LayerCompression.ZIP;
    tiffSaveOptions.interleaveChannels = true;
    tiffSaveOptions.alphaChannels = true;
    tiffSaveOptions.annotations = true;
    tiffSaveOptions.spotColors = true;
    tiffSaveOptions.saveImagePyramid = false;
    // NONE | JPEG | TIFFLZW | TIFFZIP
    tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
    app.activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}

 

 

The script can be modified to save out a TIFF if it otherwise performs as required... What TIFF save options are needed?

 

EDIT: I have updated the code with TIFF save options rather than JPEG.

 

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

 

Likes

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
Reply
Loading...
Oct 19, 2020 3
Most Valuable Participant ,
Oct 20, 2020

Copy link to clipboard

Copied

The script  saved flat Jpeg so they could be used on the web.  There a Save PSD option that can save layer files if  you want to be able to tweak or edit the populated template.  With your modification they need to tun a second batch job to save the Tiff Files as jpeg.  You should have changed the save PSD option to Save Tiff option.

JJMack

Likes

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
Reply
Loading...
Oct 20, 2020 0
Community Beginner ,
Oct 20, 2020

Copy link to clipboard

Copied

Works great 😄

Thank you all for your help 🙂

Likes

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
Reply
Loading...
Oct 20, 2020 0
Adobe Community Professional ,
Oct 27, 2020

Copy link to clipboard

Copied

Thanks for the feedback, please mark the answer/answers that helped you as correct so that others with the same issue know that there is a solution.

Likes

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
Reply
Loading...
Oct 27, 2020 2
Community Beginner ,
Nov 04, 2020

Copy link to clipboard

Copied

Great job!!!!!!!!!!!!!!

Likes

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
Reply
Loading...
Nov 04, 2020 1
Adobe Community Professional ,
Nov 04, 2020

Copy link to clipboard

Copied

Thank you for coming back and marking a correct answer.

Likes

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
Reply
Loading...
Nov 04, 2020 1
Community Beginner ,
Nov 04, 2020

Copy link to clipboard

Copied

Thank you for your time and your help 🙂

Likes

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
Reply
Loading...
Nov 04, 2020 0