// SCRIPT LOGIC // for site in sites: // for year in years: // register_images() // VARIABLE DEFINITIONS // images_to_register = All images to be registered for a given site and year (no target or seed) // batch_images_to_register = Batch images to be registered (no target or seed) // batch_images_all = Target, seed and batch images to be registered var batch_size = 15; // Retrieve data in coastsnap_sites.csv var parent_dir = File($.fileName).parent.parent.fsName; var batch_download_csv = File(parent_dir + "/coastsnap_sites.csv") // retreive site names from batch_download.csv var csv_data=[]; batch_download_csv.open('r'); while(!batch_download_csv.eof){ var InputLine = batch_download_csv.readln(); if(InputLine.length > 3) csv_data.push(InputLine); } batch_download_csv.close(); var site_names = csv_data.toString().split(",") // Retrieve images parent directory from CoastSnap_Sites.csv var parent_folder_path = File(site_names[9]); var batch_images_to_register = []; // Used in exportLayersToPNG // Loop through sites for(var i=5; i= layer_width) { var s = (target_height/layer_height)*100; } else { var s = (target_width/layer_width)*100; } current_layer.resize(s, s, AnchorPosition.TOPLEFT) } } function selectAllLayers() { var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); desc.putReference( charIDToTypeID('null'), ref ); executeAction( stringIDToTypeID('selectAllLayers'), desc, DialogModes.NO ); }; function autoAlign() { var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); desc.putReference( charIDToTypeID('null'), ref ); desc.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('ADSt'), stringIDToTypeID('ADSContent') ); desc.putEnumerated( charIDToTypeID('Aply'), stringIDToTypeID('projection'), charIDToTypeID('Auto') ); desc.putBoolean( stringIDToTypeID('vignette'), false ); desc.putBoolean( stringIDToTypeID('radialDistort'), false ); executeAction( charIDToTypeID('Algn'), desc, DialogModes.NO ); }; function lockTarget() { var layerRef = app.activeDocument.artLayers.getByName("Target.jpg") layerRef.allLocked = true; app.activeDocument.activeLayer.linkedLayers } // CROP function cropToTarget() { var layerRef = app.activeDocument.artLayers.getByName("Target.jpg") app.activeDocument.crop(layerRef.bounds) var theBounds = app.activeDocument.activeLayer.bounds; var layerWidth = theBounds[2] - theBounds[0]; var layerHeight = theBounds[3] - theBounds[1]; return [layerWidth, layerHeight]; } // TO BE IMPLEMENTED // function imageSize(layerRef) { // } // SAVE PHOTOSHOP DOCUMENT function savePhotoshopDocument(site_path, site_name) { var PSdocumentFile = new File(site_path + '/' + site_name + '.psd'); app.activeDocument.saveAs(PSdocumentFile) } // EXPORT LAYERS TO IMAGES // $.evalFile(File(app.path + '/Presets/Scripts/Export Layers To Files.jsx')); function exportLayersToPNG(target_width, target_height, batch_images_to_register, seed_images){ if(!documents.length) return; var doc = activeDocument; var oldPath = activeDocument.path; var outFolder = new Folder(oldPath + "/Photoshop/" + year); if (!outFolder.exists) { outFolder.create(); } scanLayerSets(doc); function scanLayerSets(el) { // // find layer groups // for(var a=0;a