Copy link to clipboard
Copied
I have 2 folders of images.
1 folder has images with a watermark on the lower left side of the image & the other folder has images with a watermark on the lower right side.
The images are named the same in each folder.
I've never done scripting before & I don't want to edit, flatten & save 2000 images by hand.
There has to be an efficient way of doing this.
Any help is much appreciated.
Thanks!
I have brought the top down a little, it's now 4/5th removed from the top.
var top = activeDocument.height-((activeDocument.height/5)*4);
The whole script again..
...#target photoshop
function main(){
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,650,290],"+
"panel0:Panel{bounds:[10,10,540,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[190,10,360,27] , text:'Merge Files' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel
Copy link to clipboard
Copied
This should be close.....
#target photoshop
function main(){
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,650,290],"+
"panel0:Panel{bounds:[10,10,540,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[190,10,360,27] , text:'Merge Files' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,30,520,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,70,30] , text:'Folder A' ,properties:{scrolling:undefined,multiline:undefined}},"+
"foldera:EditText{bounds:[80,10,430,30] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse1:Button{bounds:[440,10,501,31] , text:'<<' },"+
"statictext2:StaticText{bounds:[10,40,70,57] , text:'Folder B' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderb:EditText{bounds:[80,40,430,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse2:Button{bounds:[440,40,500,61] , text:'<<' },"+
"statictext3:StaticText{bounds:[10,70,70,87] , text:'Output' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderc:EditText{bounds:[80,70,430,90] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse3:Button{bounds:[440,70,501,91] , text:'>>' }},"+
"Process:Button{bounds:[10,140,260,161] , text:'Process' },"+
"button4:Button{bounds:[270,140,520,161] , text:'Cancel' }}};"
var win = new Window(dlg,'Merge Files');
win.center();
win.panel0.panel1.foldera.enabled=false;
win.panel0.panel1.folderb.enabled=false;
win.panel0.panel1.folderc.enabled=false;win.panel0.panel1.Browse1.onClick = function() {
inputFolder1 = Folder.selectDialog("Please select the folder with Files A to process");
if(inputFolder1 !=null){
win.panel0.panel1.foldera.text = decodeURI(inputFolder1.fsName);
}
}
win.panel0.panel1.Browse2.onClick = function() {
inputFolder2 = Folder.selectDialog("Please select the folder with Files B to process");
if(inputFolder2 !=null){
win.panel0.panel1.folderb.text = decodeURI(inputFolder2.fsName);
}
}
win.panel0.panel1.Browse3.onClick = function() {
outputFolder = Folder.selectDialog("Please select the output folder");
if(outputFolder !=null){
win.panel0.panel1.folderc.text = decodeURI(outputFolder.fsName);
}
}
win.panel0.Process.onClick = function(){
if(win.panel0.panel1.foldera.text == ''){
alert("Folder A has not been selected!");
return;
}
if(win.panel0.panel1.folderb.text == ''){
alert("Folder B has not been selected!");
return;
}
if(win.panel0.panel1.folderc.text == ''){
alert("Output folder has not been selected!");
return;
}
win.close(1);
processDocuments();
}
win.show();
function processDocuments(){
var fileListA = inputFolder1.getFiles(/\.(jpg|tif|psd|png)$/i);
for (var a in fileListA){
var file = fileListA;
var fileb = File(inputFolder2+"/"+file.name);
if(!fileb.exists) continue;
var saveFile = File(outputF...
Copy link to clipboard
Copied
All this did was essentially copy 1 folder's images to a new folder.
I need the lower left portion of images A to be covered up by the lower left portion of images B.
image A has the watermark on the lower left and image B has the watermark on the lower right.
Copy link to clipboard
Copied
What the script does is merge both files and save out the result as you requested. You will need to supply more detail. What format are your input files?, also example files would be a great help.
Copy link to clipboard
Copied
Add these two line to Paul's script after rasterLayer(); and before saveJpeg
activeDocument.selection.select( [[0,0],[activeDocument.width/2,0],[activeDocument.width/2,activeDocument.height],[0,activeDocument.height]]);
activeDocument.selection.clear();
This will clear the left half of the activeLayer, hopefully that is where the watermark is on that layer. You may have to edit the selection bounds to clear the right side as it's not clear which on which side the watermark is on the activeLayer.
You will also need to set the ruler units to pixels.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Mike is spot on, there does seem to be a slight difference in colours in the two pics.
Here is the code with Mike's refinement added. (Thanks Mike)
#target photoshop
function main(){
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,650,290],"+
"panel0:Panel{bounds:[10,10,540,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[190,10,360,27] , text:'Merge Files' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,30,520,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,70,30] , text:'Folder A' ,properties:{scrolling:undefined,multiline:undefined}},"+
"foldera:EditText{bounds:[80,10,430,30] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse1:Button{bounds:[440,10,501,31] , text:'<<' },"+
"statictext2:StaticText{bounds:[10,40,70,57] , text:'Folder B' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderb:EditText{bounds:[80,40,430,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse2:Button{bounds:[440,40,500,61] , text:'<<' },"+
"statictext3:StaticText{bounds:[10,70,70,87] , text:'Output' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderc:EditText{bounds:[80,70,430,90] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse3:Button{bounds:[440,70,501,91] , text:'>>' }},"+
"Process:Button{bounds:[10,140,260,161] , text:'Process' },"+
"button4:Button{bounds:[270,140,520,161] , text:'Cancel' }}};"
var win = new Window(dlg,'Merge Files');
win.center();
win.panel0.panel1.foldera.enabled=false;
win.panel0.panel1.folderb.enabled=false;
win.panel0.panel1.folderc.enabled=false;win.panel0.panel1.Browse1.onClick = function() {
inputFolder1 = Folder.selectDialog("Please select the folder with Files A to process");
if(inputFolder1 !=null){
win.panel0.panel1.foldera.text = decodeURI(inputFolder1.fsName);
}
}
win.panel0.panel1.Browse2.onClick = function() {
inputFolder2 = Folder.selectDialog("Please select the folder with Files B to process");
if(inputFolder2 !=null){
win.panel0.panel1.folderb.text = decodeURI(inputFolder2.fsName);
}
}
win.panel0.panel1.Browse3.onClick = function() {
outputFolder = Folder.selectDialog("Please select the output folder");
if(outputFolder !=null){
win.panel0.panel1.folderc.text = decodeURI(outputFolder.fsName);
}
}
win.panel0.Process.onClick = function(){
if(win.panel0.panel1.foldera.text == ''){
alert("Folder A has not been selected!");
return;
}
if(win.panel0.panel1.folderb.text == ''){
alert("Folder B has not been selected!");
return;
}
if(win.panel0.panel1.folderc.text == ''){
alert("Output folder has not been selected!");
return;
}
win.close(1);
processDocuments();
}
win.show();
function processDocuments(){
var fileListA = inputFolder1.getFiles(/\.(jpg|tif|psd|png)$/i);
for (var a in fileListA){
var file = fileListA;
var fileb = File(inputFolder2+"/"+file.name);
if(!fileb.exists) continue;
var saveFile = File(outputF...
Copy link to clipboard
Copied
Paul, this doesn't seem to do anything.
I put in the 2 folder paths and the destination folder and after I hit process it does nothing.
The images are named the same in both the folders.
Copy link to clipboard
Copied
That could be one of two reasons, the first being the folders have been selected the wrong way round or the input files are not one of jpg, tif, psd or png.
Could you try entering the folders A & B reversed and see if you get the desired result.
Copy link to clipboard
Copied
I had to rename the extensions back to png instead of jpg.
How can I control what part of image B is overlapped with image A?
I didn't realize there was a large center watermark on some of the images.
What if I wanted to overlap the lower left section with the rest of the other image?
I noticed it's overlapping 50% of each of the images.
I attached one of the images to show you.
Copy link to clipboard
Copied
I am still guessing on how much needs to be retained, could you see if this is near?
#target photoshop
function main(){
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,650,290],"+
"panel0:Panel{bounds:[10,10,540,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[190,10,360,27] , text:'Merge Files' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,30,520,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,70,30] , text:'Folder A' ,properties:{scrolling:undefined,multiline:undefined}},"+
"foldera:EditText{bounds:[80,10,430,30] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse1:Button{bounds:[440,10,501,31] , text:'<<' },"+
"statictext2:StaticText{bounds:[10,40,70,57] , text:'Folder B' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderb:EditText{bounds:[80,40,430,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse2:Button{bounds:[440,40,500,61] , text:'<<' },"+
"statictext3:StaticText{bounds:[10,70,70,87] , text:'Output' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderc:EditText{bounds:[80,70,430,90] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse3:Button{bounds:[440,70,501,91] , text:'>>' }},"+
"Process:Button{bounds:[10,140,260,161] , text:'Process' },"+
"button4:Button{bounds:[270,140,520,161] , text:'Cancel' }}};"
var win = new Window(dlg,'Merge Files');
win.center();
win.panel0.panel1.foldera.enabled=false;
win.panel0.panel1.folderb.enabled=false;
win.panel0.panel1.folderc.enabled=false;win.panel0.panel1.Browse1.onClick = function() {
inputFolder1 = Folder.selectDialog("Please select the folder with Files A to process");
if(inputFolder1 !=null){
win.panel0.panel1.foldera.text = decodeURI(inputFolder1.fsName);
}
}
win.panel0.panel1.Browse2.onClick = function() {
inputFolder2 = Folder.selectDialog("Please select the folder with Files B to process");
if(inputFolder2 !=null){
win.panel0.panel1.folderb.text = decodeURI(inputFolder2.fsName);
}
}
win.panel0.panel1.Browse3.onClick = function() {
outputFolder = Folder.selectDialog("Please select the output folder");
if(outputFolder !=null){
win.panel0.panel1.folderc.text = decodeURI(outputFolder.fsName);
}
}
win.panel0.Process.onClick = function(){
if(win.panel0.panel1.foldera.text == ''){
alert("Folder A has not been selected!");
return;
}
if(win.panel0.panel1.folderb.text == ''){
alert("Folder B has not been selected!");
return;
}
if(win.panel0.panel1.folderc.text == ''){
alert("Output folder has not been selected!");
return;
}
win.close(1);
processDocuments();
}
win.show();
function processDocuments(){
var fileListA = inputFolder1.getFiles(/\.(jpg|tif|psd|png)$/i);
for (var a in fileListA){
var file = fileListA;
var fileb = File(inputFolder2+"/"+file.name);
if(!fileb.exists) continue;
var saveFile = File(outputF...
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have brought the top down a little, it's now 4/5th removed from the top.
var top = activeDocument.height-((activeDocument.height/5)*4);
The whole script again..
#target photoshop
function main(){
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,650,290],"+
"panel0:Panel{bounds:[10,10,540,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext0:StaticText{bounds:[190,10,360,27] , text:'Merge Files' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,30,520,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,70,30] , text:'Folder A' ,properties:{scrolling:undefined,multiline:undefined}},"+
"foldera:EditText{bounds:[80,10,430,30] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse1:Button{bounds:[440,10,501,31] , text:'<<' },"+
"statictext2:StaticText{bounds:[10,40,70,57] , text:'Folder B' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderb:EditText{bounds:[80,40,430,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse2:Button{bounds:[440,40,500,61] , text:'<<' },"+
"statictext3:StaticText{bounds:[10,70,70,87] , text:'Output' ,properties:{scrolling:undefined,multiline:undefined}},"+
"folderc:EditText{bounds:[80,70,430,90] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse3:Button{bounds:[440,70,501,91] , text:'>>' }},"+
"Process:Button{bounds:[10,140,260,161] , text:'Process' },"+
"button4:Button{bounds:[270,140,520,161] , text:'Cancel' }}};"
var win = new Window(dlg,'Merge Files');
win.center();
win.panel0.panel1.foldera.enabled=false;
win.panel0.panel1.folderb.enabled=false;
win.panel0.panel1.folderc.enabled=false;win.panel0.panel1.Browse1.onClick = function() {
inputFolder1 = Folder.selectDialog("Please select the folder with Files A to process");
if(inputFolder1 !=null){
win.panel0.panel1.foldera.text = decodeURI(inputFolder1.fsName);
}
}
win.panel0.panel1.Browse2.onClick = function() {
inputFolder2 = Folder.selectDialog("Please select the folder with Files B to process");
if(inputFolder2 !=null){
win.panel0.panel1.folderb.text = decodeURI(inputFolder2.fsName);
}
}
win.panel0.panel1.Browse3.onClick = function() {
outputFolder = Folder.selectDialog("Please select the output folder");
if(outputFolder !=null){
win.panel0.panel1.folderc.text = decodeURI(outputFolder.fsName);
}
}
win.panel0.Process.onClick = function(){
if(win.panel0.panel1.foldera.text == ''){
alert("Folder A has not been selected!");
return;
}
if(win.panel0.panel1.folderb.text == ''){
alert("Folder B has not been selected!");
return;
}
if(win.panel0.panel1.folderc.text == ''){
alert("Output folder has not been selected!");
return;
}
win.close(1);
processDocuments();
}
win.show();
function processDocuments(){
var fileListA = inputFolder1.getFiles(/\.(jpg|tif|psd|png)$/i);
for (var a in fileListA){
var file = fileListA;
var fileb = File(inputFolder2+"/"+file.name);
if(!fileb.exists) continue;
var saveFile = File(outputF...
Copy link to clipboard
Copied
Thanks! I just changed it to *2 and it takes off enough that there is only a small portion of the center watermark that it isn't noticable.