Highlighted

AUTOMATE, BATCH, ACTION, mask import !!!

Community Beginner ,
Sep 27, 2020

Copy link to clipboard

Copied

Hello, 

I need to process sequence of images using Batch. 

There is such command File -> Place Embedded, in one step of Action. (import of a mask - PNG image with alpha chennel)

I need to achieve that for each subsequent image, a mask with the next index number is imported. 

That is, for Image1 - Mask1, for Image2 - Mask2, for Image3 - Mask3 etc. 

 

sor far, for each subsequent image, the Action imports the same mask 

(the image that was specified while action recording)

 

That is, for Image1 - Mask1, for Image2 - Mask1, for Image3 - Mask1 etc. 

 

Please tell me te sollution! 

Thank you in advance!

 

 

 

TOPICS
Actions and scripting, How to, Import and export, Performance

Views

177

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

AUTOMATE, BATCH, ACTION, mask import !!!

Community Beginner ,
Sep 27, 2020

Copy link to clipboard

Copied

Hello, 

I need to process sequence of images using Batch. 

There is such command File -> Place Embedded, in one step of Action. (import of a mask - PNG image with alpha chennel)

I need to achieve that for each subsequent image, a mask with the next index number is imported. 

That is, for Image1 - Mask1, for Image2 - Mask2, for Image3 - Mask3 etc. 

 

sor far, for each subsequent image, the Action imports the same mask 

(the image that was specified while action recording)

 

That is, for Image1 - Mask1, for Image2 - Mask1, for Image3 - Mask1 etc. 

 

Please tell me te sollution! 

Thank you in advance!

 

 

 

TOPICS
Actions and scripting, How to, Import and export, Performance

Views

178

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
Sep 27, 2020 0
Community Beginner ,
Sep 27, 2020

Copy link to clipboard

Copied

images are located in folder A

masks   are located in folder B

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...
Sep 27, 2020 0
Most Valuable Participant ,
Sep 27, 2020

Copy link to clipboard

Copied

What do you mean by masks are in folder b.  What are your masks files? How do Photoshop document the images and mask are imported get into Photoshop. How many  images and mask get are imported into a document.  How are they arranged or align in you documents. Photoshop Batch opens one image at time and plays the batch action on the opened document before moving on to the next sequential image.  Actions can not use any logic the find what the current open document name is to match a image to a mask. Actions steps are fixed  they can not use logic to set an import mask file that need to imported.   What you want to can not be automated via Photoshop action. You may be able to do automated what you want to do using Photoshop scripting.  However, what you posted can not be automated for you description is that of an incomplete process. I have no idea of what you actually want to do.  You noted Batch, Image, automating image  masking via mask file using Actions.  Even if you supply the missing details  I do not believe your process could be automated via a Photoshop batch action.

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...
Sep 27, 2020 1
Community Beginner ,
Sep 28, 2020

Copy link to clipboard

Copied

Hello,

thank you for your respond!

I already know that I need a script.

 

I need to process sequence of images in such way:

Folder 1 contains

sequence:

 

image1

image2

image100

 

Folder 2 contains

sequence:

 

mask1

mask2

mask100

 

masks are PNG+alpha

 

For every subsequent image, Batch must run Action, and import PNG mask with next subsequent index.

Then complete Action, save processed image in folder 3, and close document.

Then open next image, and repeat the process.

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...
Sep 28, 2020 0
LEGEND ,
Sep 28, 2020

Copy link to clipboard

Copied

I think posting meaningful screenshots of the Folders and some sample files with the intended results would have been helpful. 

So far I am not sure, for example, if the masks are grayscale or RGB. 

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...
Sep 28, 2020 1
Community Beginner ,
Sep 28, 2020

Copy link to clipboard

Copied

So far I am not sure, for example, if the masks are grayscale or RGB

Action users masks to determine countour of central object, it uses only Alpha channel

 

There is needed script for described task. 

script which can add +1 to index of a mask, in every step when action imports next file. 

 

 

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...
Sep 28, 2020 0
LEGEND ,
Sep 28, 2020

Copy link to clipboard

Copied

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...
Sep 28, 2020 1
LEGEND ,
Sep 28, 2020

Copy link to clipboard

Copied

I found another old Script you might be able change to meet your needs. 

// combine images from  two folders;
// 2016, use it at your own risk;
#target photoshop
// select folders;
var theFolder1 = Folder.selectDialog ("select folder");
if (theFolder1) {
var theFolder2 = Folder.selectDialog ("select other folder");
if (theFolder2 && String(theFolder1) != String(theFolder2)) {
// get files;
var theFiles1 = theFolder1.getFiles(/\.(jpg|tif|eps|psd)$/i);
var theFiles2 = theFolder2.getFiles(/\.(jpg|tif|eps|psd)$/i);
// if more than one image is in the folder and equal number in both;
if (theFiles1.length > 0 && theFiles2.length == theFiles1.length) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = true;
// do the operation;
for (var m = 0; m < theFiles1.length; m++) {
var theFile = theFiles1[m];
var theOtherFile = theFiles2[m];
// create file;
var myDocument = app.open(File(theFile));
var docName = myDocument.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = myDocument.path;
// place the corresponding file;
placeScaleFile (theOtherFile, 0, 0, 100);
//save tif as a copy:
myDocument.saveAs((new File(Folder(theFolder1).parent+"/"+basename+"_combined"+".tif")),tifOpts,true);
myDocument.close(SaveOptions.DONOTSAVECHANGES)
}
};
alert ("done")
}
};
////// get from subfolders //////
function retrieveJPGs (theFolder, theFiles) {
	if (!theFiles) {var theFiles = []};
	var theContent = theFolder.getFiles();
	for (var n = 0; n < theContent.length; n++) {
		var theObject = theContent[n];
		if (theObject.constructor.name == "Folder") {
			theFiles = retrieveJPGs(theObject, theFiles)
			};
		if (theObject.name.slice(-4) == ".jpg" || theObject.name.slice(-4) == ".JPG") {
			theFiles = theFiles.concat(theObject)
			}
		};
	return theFiles
	};
////// place //////
function placeScaleFile (file, xOffset, yOffset, theScale) {
// =======================================================
var idPlc = charIDToTypeID( "Plc " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    desc5.putPath( idnull, new File( file ) );
    var idFTcs = charIDToTypeID( "FTcs" );
    var idQCSt = charIDToTypeID( "QCSt" );
    var idQcsa = charIDToTypeID( "Qcsa" );
    desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
    var idOfst = charIDToTypeID( "Ofst" );
        var desc6 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idHrzn, idPxl, xOffset );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idVrtc, idPxl, yOffset );
    var idOfst = charIDToTypeID( "Ofst" );
    desc5.putObject( idOfst, idOfst, desc6 );
    var idWdth = charIDToTypeID( "Wdth" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idWdth, idPrc, theScale );
    var idHght = charIDToTypeID( "Hght" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idHght, idPrc, theScale );
    var idLnkd = charIDToTypeID( "Lnkd" );
    desc5.putBoolean( idLnkd, false );
executeAction( idPlc, desc5, DialogModes.NO );
return app.activeDocument.activeLayer;
};

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...
Sep 28, 2020 3
Adobe Community Professional ,
Sep 28, 2020

Copy link to clipboard

Copied

In case you can not figure out how to write or modify script for your project keep in mind that you have solution using actions but you must do some manual work: to select which mask to be imported. This can be achieved by enabling modal control for step Place (arrow pointing to modal control on my screenshot below) or use Insert Menu Item to record Select Place menu item.

place step.jpg

 

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...
Sep 28, 2020 0
Community Beginner ,
Oct 01, 2020

Copy link to clipboard

Copied

Thanks to all for your answers, I solved this question in another way

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 01, 2020 0
Advocate ,
Oct 01, 2020

Copy link to clipboard

Copied

And do you wanna tell us, how do you solved it?

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 01, 2020 1
Community Beginner ,
Oct 01, 2020

Copy link to clipboard

Copied

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 01, 2020 0