Copy link to clipboard
Copied
Hello all ,
I want to match colors between two images for a set of 100 pairs . Is it possible in Adobe photoshop to automate the process of matching colors for an entire folder of 100 pair of images .
@277251443czo – Try the following script:
/*
Match Color File Pairs From 2 Source Folders.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/regarding-batch-processing-for-color-matching/td-p/13449438
Stephen Marsh, v1.0 - 28th December 2022
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-script/td-p/12700356
*/
#target photoshop
(function () {
if (app.documents.length === 0) {
try {
// Input folder 1
...
Copy link to clipboard
Copied
Not really. Beyond the various "auto..." functions already there there's no way to match multiple photos consistently without actually opening them and manually dialling in a few tweaks.
Mylenium
Copy link to clipboard
Copied
A script can batch open pairs of images for processing, but once the two images are open how do you plan to "colour match" them?
Copy link to clipboard
Copied
Hi Stephen ,
I have a folder of stereo pair of images , i want to match the colors of right image with the left image .
For an individual pair , I will open both the images (left and right pair) and I will go to the second image and then
(Image--> Adjustments--> Match color (Will set the source to the left image.)
I want to know if it is possible to automate for a folder of image pairs .
Is it possible with scripting?
Thanking you,
Copy link to clipboard
Copied
If you have tested that this works to your satisfaction when performed manually, then yes, this can be scripted.
How are the file pairs named and is this consistent for alphabetical sorting? Such as:
File-A.jpg
File-B.jpg
File-C.jpg
File-D.jpg
Or perhaps:
Doc1A.jpg
Doc1B.jpg
Doc2A.jpg
Doc2B.jpg
Which file would be the source and which the destination?
Do you require a particular layer stack, or just a flattened result?
What file format and options should the file be saved to?
Do you wish to create a new 3rd file, or overwrite the file that has been processed?
What else?
Copy link to clipboard
Copied
Both the left and right files have same name and they are named as 1_rgb_gain_0.png, 2_rgb_gain_1.png ........etc . and they are in different folders .( all the left images in one folder and right in another).
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK, so two different input folders, both files named the same, this is workable!
For safety, it would be better to save to either a different filename or a new folder. You can always delete the destination files once you are happy.
From a scripting perspective, it is not about "left or right," it will be about which folder/image is opened first... So, if the script first opens the source folder and image, then secondly opens the destination folder and image, then there is a known order of open docs for the script to navigate.
Copy link to clipboard
Copied
Okay , Will try to do that .
Thank you so much .
I know it is too much to ask for , if possible can you share any links/references for scripting in such way.
Copy link to clipboard
Copied
Okay , Will try to do that .
Thank you so much .
I know it is too much to ask for , if possible can you share any links/references for scripting in such way.
By @277251443czo
It's all good, I'll provide the custom script. If this then sparks an interest in scripting, then there are countless resources available.
Copy link to clipboard
Copied
@277251443czo – Try the following script:
/*
Match Color File Pairs From 2 Source Folders.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/regarding-batch-processing-for-color-matching/td-p/13449438
Stephen Marsh, v1.0 - 28th December 2022
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-script/td-p/12700356
*/
#target photoshop
(function () {
if (app.documents.length === 0) {
try {
// Input folder 1
var folder1 = Folder.selectDialog("Select the source image folder:");
if (folder1 === null) {
alert('Script cancelled!');
return;
}
// Input folder 2
var folder2 = Folder.selectDialog("Select the destination image folder:");
if (folder2 === null) {
alert('Script cancelled!');
return;
}
// Validate input folder selection
var validateInputDir = (folder1.fsName === folder2.fsName);
if (validateInputDir === true) {
alert("Script cancelled as both the input folders are the same!");
return;
}
// Limit the file input to png
var list1 = folder1.getFiles(/\.(png)$/i);
var list2 = folder2.getFiles(/\.(png)$/i);
// Alpha-numeric sort
list1.sort();
list2.sort();
// Validate that folder 1 & 2 lists are not empty
var validateEmptyList = (list1.length > 0 && list2.length > 0);
if (validateEmptyList === false) {
alert("Script cancelled as one of the input folders is empty or doesn't contain PNG files!");
return;
}
// Validate that the item count in folder 1 & 2 matches
var validateListLength = (list1.length === list2.length);
if (validateListLength === false) {
alert("Script cancelled as the input folders don't have equal quantities of images!");
return;
}
// Output folder
var saveFolder = Folder.selectDialog("Please select the folder to save to...");
// Save and set the dialog display settings
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;
// PNG save options
var pngOptions = new PNGSaveOptions();
pngOptions.compression = 0; // compression value: 0-9
pngOptions.interlaced = false;
// Set the file processing counter
var counter = 0;
// Perform the processing and saving
for (var i = 0; i < list1.length; i++) {
open(list1[i]);
var doc2 = open(list2[i]);
var docName = doc2.name.replace(/\.[^\.]+$/, '.png');
matchColor(100, 100, 0, true);
doc2.saveAs(new File(saveFolder + '/' + docName), pngOptions);
counter++;
while (app.documents.length > 0) {
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
// End of script
app.displayDialogs = savedDisplayDialogs;
app.beep();
alert('Script completed!' + '\r' + counter + ' output files of ' + list1.length + ' input file pairs saved to:' + '\r' + saveFolder.fsName);
} catch (err) {
while (app.documents.length > 0) {
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
alert(err);
}
} else {
alert('Please close all open documents before running this script!');
}
function matchColor(lightness, colorRange, fade, selection) {
var sourceDoc = app.documents[0].name; // [0] - the first doc open
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
descriptor.putInteger(s2t("lightness"), lightness);
descriptor.putInteger(s2t("colorRange"), colorRange);
descriptor.putInteger(s2t("fade"), fade);
descriptor.putBoolean(s2t("selection"), selection);
reference.putProperty(s2t("layer"), s2t("background"));
reference.putName(s2t("document"), sourceDoc); // variable for source doc name
descriptor.putReference(s2t("source"), reference);
executeAction(s2t("matchColor"), descriptor, DialogModes.NO);
}
}());
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop
Copy link to clipboard
Copied
Thank you so much Stephen . This helped me a lot .
Copy link to clipboard
Copied
@277251443czo – You’re welcome!