Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

How can I load multiple images into Photoshop and search if they have white or transparent background ?

$
0
0

Hi,

 

I need to this :

  1. Open script (in photoshop)
  2. Select folder
  3. Check background color is white or transparent of all images in the folder
  4. If an image does not have a white or a transparent background, add "_check" to the end of the name of the image (and change
  5. Open next folder
  6. Etc

 

I am really new with JavaScript in Photoshop, I manage to find and write a small part of this code

 

#target photoshop


var topFolder = new Folder('~/desktop/test');
var fileandfolderAr = scanSubFolders(topFolder,/\.(jpg|tif|psd|bmp|gif|png|)$/i);
var fileList = fileandfolderAr[0];
for(var a = 0 ;a < fileList.length; a++)


for(var a = 0 ;a < fileList.length; a++)
{
var docRef = open(fileList[a]);
//do things here
}
function scanSubFolders(tFolder, mask) { // folder object, RegExp or string    var sFolders = new Array();    var allFiles = new Array();    sFolders[0] = tFolder;    for (var j = 0; j < sFolders.length; j++){ // loop through folders                    var procFiles = sFolders[j].getFiles();        for (var i=0;i<procFiles.length;i++){ // loop through this folder contents            if (procFiles[i] instanceof File ){                if(mask==undefined) allFiles.push(procFiles[i]);// if no search mask collect all files                if (procFiles[i].fullName.search(mask) != -1) allFiles.push(procFiles[i]); // otherwise only those that match mask        }else if (procFiles[i] instanceof Folder){            sFolders.push(procFiles[i]);// store the subfolder            scanSubFolders(procFiles[i], mask);// search the subfolder         }      }   }   return [allFiles,sFolders];
};


var docRef = app.activeDocument;
var activeLay = docRef.activeLayer;


  var newLayer = activeDocument.artLayers.add(); // Create a new ArtLayer object  newLayer.name = "_check";


docRef.selection.selectAll();


var colorRef= new SolidColor();
colorRef.rgb.red = 255;
colorRef.rgb.green = 255;
colorRef.rgb.blue = 255;
// Apply fill to the current selection
docRef.selection.fill(colorRef);


docRef.selection.invert();

activeDocument = docRef
docRef.activeLayer = docRef.layers[1]





















Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>