├── README.md ├── equalize-textures.jsx ├── offset_texture_for_clone_stamping_seams.jsx ├── reaction-diffusion-v2.jsx ├── reaction-diffusion.jsx └── contentawarebatch.jsx /README.md: -------------------------------------------------------------------------------- 1 | # Photoshop Scripts 2 | 3 | My collection of Adobe Photoshop scripts. -------------------------------------------------------------------------------- /equalize-textures.jsx: -------------------------------------------------------------------------------- 1 | var hpradius = 100; // high-pass radius 2 | // ------------------------------------ 3 | var doc = app.activeDocument; 4 | var layer = doc.activeLayer; 5 | layer.duplicate(); 6 | var dub = doc.artLayers.getByName(layer.name+" copy"); 7 | dub.blendMode = BlendMode.LINEARLIGHT; 8 | dub.opacity = 50; 9 | dub.applyHighPass(hpradius); 10 | layer.applyAverage(); 11 | dub.merge(); -------------------------------------------------------------------------------- /offset_texture_for_clone_stamping_seams.jsx: -------------------------------------------------------------------------------- 1 | #target photoshop 2 | 3 | var doc = app.activeDocument; 4 | preferences.rulerUnits = Units.PIXELS; 5 | 6 | var height = doc.height.as('px'); 7 | var width = doc.width.as('px'); 8 | 9 | var idOfst = charIDToTypeID( "Ofst" ); 10 | var desc7 = new ActionDescriptor(); 11 | var idHrzn = charIDToTypeID( "Hrzn" ); 12 | desc7.putInteger( idHrzn, width/2 ); 13 | var idVrtc = charIDToTypeID( "Vrtc" ); 14 | desc7.putInteger( idVrtc, height/2 ); 15 | var idFl = charIDToTypeID( "Fl " ); 16 | var idFlMd = charIDToTypeID( "FlMd" ); 17 | var idWrp = charIDToTypeID( "Wrp " ); 18 | desc7.putEnumerated( idFl, idFlMd, idWrp ); 19 | executeAction( idOfst, desc7, DialogModes.NO ); -------------------------------------------------------------------------------- /reaction-diffusion-v2.jsx: -------------------------------------------------------------------------------- 1 | #target photoshop 2 | //////////////////////////////////////////////////////////////////////////////////////// 3 | // reaction diffusion script 4 | // http://twitter.com/aturtur 5 | //////////////////////////////////////////////////////////////////////////////////////// 6 | // 1. make a new document with a white background 7 | // 2. paint some black stuff around the canvas 8 | // 3. save your document into the folder 9 | // 4. make sure your layer is selected, then run the script 10 | // 5. frames will be saved to your document path, layer name will be filename 11 | //////////////////////////////////////////////////////////////////////////////////////// 12 | // change these variables to get nice results 13 | var highpass = 6; 14 | var threshold = 120; 15 | var gaussianblur = 3; 16 | //-------------------------------------------------------------------------------------- 17 | var iterations = 500; 18 | var saveEveryNthFrame = 2; 19 | //////////////////////////////////////////////////////////////////////////////////////// 20 | var doc = app.activeDocument; 21 | var layer = doc.activeLayer; 22 | var pad = "0000"; 23 | function savePNG(number){ 24 | var pngOptions = new PNGSaveOptions(); 25 | var path = File(doc.path + "/" + layer.name +"_"+(pad+number).slice(-pad.length)+"_"+ ".png"); 26 | doc.saveAs(path, pngOptions, true, Extension.LOWERCASE); 27 | } 28 | for (var i = 0; i < iterations; i++) { 29 | layer.applyHighPass(highpass); 30 | var idThrs = charIDToTypeID( "Thrs" ); 31 | var desc11 = new ActionDescriptor(); 32 | var idLvl = charIDToTypeID( "Lvl " ); 33 | desc11.putInteger( idLvl, threshold ); 34 | executeAction( idThrs, desc11, DialogModes.NO ); 35 | layer.applyGaussianBlur(gaussianblur); 36 | var number = i / saveEveryNthFrame; 37 | 38 | if (i % saveEveryNthFrame == 0) { 39 | savePNG(number); 40 | } 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /reaction-diffusion.jsx: -------------------------------------------------------------------------------- 1 | #target photoshop 2 | //////////////////////////////////////////////////////////////////////////////////////// 3 | // reaction diffusion script 4 | // http://twitter.com/aturtur 5 | //////////////////////////////////////////////////////////////////////////////////////// 6 | // 1. make a new document with a white background 7 | // 2. paint some black stuff around the canvas 8 | // 3. save your document into the folder 9 | // 4. make sure your layer is selected, then run the script 10 | // 5. frames will be saved to your document path, layer name will be filename 11 | //////////////////////////////////////////////////////////////////////////////////////// 12 | // change these variables to get nice results 13 | var blur = 4; 14 | var multiplier = 3; 15 | var exposure = 8; 16 | var iterations = 50; 17 | var saveEveryNthFrame = 2; 18 | //////////////////////////////////////////////////////////////////////////////////////// 19 | var doc = app.activeDocument; 20 | var layer = doc.activeLayer; 21 | var pad = "0000"; 22 | function savePNG(number){ 23 | var pngOptions = new PNGSaveOptions(); 24 | var path = File(doc.path + "/" + layer.name +"_"+(pad+number).slice(-pad.length)+"_"+ ".png"); 25 | doc.saveAs(path, pngOptions, true, Extension.LOWERCASE); 26 | } 27 | for (var i = 0; i < iterations; i++) { 28 | layer.applyGaussianBlur(blur); 29 | layer.duplicate(); 30 | dub = doc.artLayers.getByName(layer.name+" copy"); 31 | dub.applyGaussianBlur(blur*multiplier); 32 | dub.blendMode = BlendMode.SUBTRACT; 33 | dub.merge(); 34 | var idExps = charIDToTypeID( "Exps" ); 35 | var desc19 = new ActionDescriptor(); 36 | var idpresetKind = stringIDToTypeID( "presetKind" ); 37 | var idpresetKindType = stringIDToTypeID( "presetKindType" ); 38 | var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" ); 39 | desc19.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom ); 40 | var idExps = charIDToTypeID( "Exps" ); 41 | desc19.putDouble( idExps, exposure ); 42 | var idOfst = charIDToTypeID( "Ofst" ); 43 | desc19.putDouble( idOfst, 0.000000 ); 44 | var idgammaCorrection = stringIDToTypeID( "gammaCorrection" ); 45 | desc19.putDouble( idgammaCorrection, 1.000000 ); 46 | executeAction( idExps, desc19, DialogModes.NO ); 47 | var number = i / saveEveryNthFrame; 48 | if (i % saveEveryNthFrame == 0) { 49 | savePNG(number); 50 | } 51 | } -------------------------------------------------------------------------------- /contentawarebatch.jsx: -------------------------------------------------------------------------------- 1 | // Content Aware Batch Script 2 | // 1. Run the script 3 | // 2. Select source footage sequence folder (TIFFs are nice) 4 | // 3. Select mask sequence folder (Alpha matte PNGs are fine) 5 | // 4. Wait 6 | // Hold ESC if you want to stop the process 7 | // This script saves TIFF-files, bit-depth is source depended 8 | 9 | // open file function 10 | function openImageFile(file) { 11 | var idOpn = charIDToTypeID( "Opn " ); 12 | var desc78 = new ActionDescriptor(); 13 | var idnull = charIDToTypeID( "null" ); 14 | desc78.putPath( idnull, file ); 15 | executeAction( idOpn, desc78, DialogModes.NO ); 16 | } 17 | // close file function 18 | function closeFile() { 19 | var idCls = charIDToTypeID( "Cls " ); 20 | var desc874 = new ActionDescriptor(); 21 | var idDocI = charIDToTypeID( "DocI" ); 22 | desc874.putInteger( idDocI, 242 ); 23 | var idforceNotify = stringIDToTypeID( "forceNotify" ); 24 | desc874.putBoolean( idforceNotify, true ); 25 | executeAction( idCls, desc874, DialogModes.NO ); 26 | } 27 | // merge documents function 28 | function mergeDocuments(destName) { 29 | var idDplc = charIDToTypeID( "Dplc" ); 30 | var desc872 = new ActionDescriptor(); 31 | var idnull = charIDToTypeID( "null" ); 32 | var ref45 = new ActionReference(); 33 | var idLyr = charIDToTypeID( "Lyr " ); 34 | var idOrdn = charIDToTypeID( "Ordn" ); 35 | var idTrgt = charIDToTypeID( "Trgt" ); 36 | ref45.putEnumerated( idLyr, idOrdn, idTrgt ); 37 | desc872.putReference( idnull, ref45 ); 38 | var idT = charIDToTypeID( "T " ); 39 | var ref46 = new ActionReference(); 40 | var idDcmn = charIDToTypeID( "Dcmn" ); 41 | ref46.putName( idDcmn, destName ); 42 | desc872.putReference( idT, ref46 ); 43 | var idVrsn = charIDToTypeID( "Vrsn" ); 44 | desc872.putInteger( idVrsn, 5 ); 45 | var idIdnt = charIDToTypeID( "Idnt" ); 46 | var list12 = new ActionList(); 47 | list12.putInteger( 2 ); 48 | desc872.putList( idIdnt, list12 ); 49 | executeAction( idDplc, desc872, DialogModes.NO ); 50 | } 51 | // create a mask selection 52 | function selectMask() { 53 | var idsetd = charIDToTypeID( "setd" ); 54 | var desc432 = new ActionDescriptor(); 55 | var idnull = charIDToTypeID( "null" ); 56 | var ref14 = new ActionReference(); 57 | var idChnl = charIDToTypeID( "Chnl" ); 58 | var idfsel = charIDToTypeID( "fsel" ); 59 | ref14.putProperty( idChnl, idfsel ); 60 | desc432.putReference( idnull, ref14 ); 61 | var idT = charIDToTypeID( "T " ); 62 | var ref15 = new ActionReference(); 63 | var idChnl = charIDToTypeID( "Chnl" ); 64 | var idChnl = charIDToTypeID( "Chnl" ); 65 | var idTrsp = charIDToTypeID( "Trsp" ); 66 | ref15.putEnumerated( idChnl, idChnl, idTrsp ); 67 | desc432.putReference( idT, ref15 ); 68 | executeAction( idsetd, desc432, DialogModes.NO ); 69 | } 70 | // content aware tool 71 | function contentAware() { 72 | var idFl = charIDToTypeID( "Fl " ); 73 | var desc12 = new ActionDescriptor(); 74 | var idUsng = charIDToTypeID( "Usng" ); 75 | var idFlCn = charIDToTypeID( "FlCn" ); 76 | var idcontentAware = stringIDToTypeID( "contentAware" ); 77 | desc12.putEnumerated( idUsng, idFlCn, idcontentAware ); 78 | var idOpct = charIDToTypeID( "Opct" ); 79 | var idPrc = charIDToTypeID( "#Prc" ); 80 | desc12.putUnitDouble( idOpct, idPrc, 100.000000 ); 81 | var idMd = charIDToTypeID( "Md " ); 82 | var idBlnM = charIDToTypeID( "BlnM" ); 83 | var idNrml = charIDToTypeID( "Nrml" ); 84 | desc12.putEnumerated( idMd, idBlnM, idNrml ); 85 | executeAction( idFl, desc12, DialogModes.NO ); 86 | } 87 | // select layer function 88 | function selectLayer(layerName) { 89 | var idslct = charIDToTypeID( "slct" ); 90 | var desc433 = new ActionDescriptor(); 91 | var idnull = charIDToTypeID( "null" ); 92 | var ref16 = new ActionReference(); 93 | var idLyr = charIDToTypeID( "Lyr " ); 94 | ref16.putName( idLyr, layerName ); 95 | desc433.putReference( idnull, ref16 ); 96 | var idMkVs = charIDToTypeID( "MkVs" ); 97 | desc433.putBoolean( idMkVs, false ); 98 | var idLyrI = charIDToTypeID( "LyrI" ); 99 | var list6 = new ActionList(); 100 | list6.putInteger( 1 ); 101 | desc433.putList( idLyrI, list6 ); 102 | executeAction( idslct, desc433, DialogModes.NO ); 103 | } 104 | // deselect selection function 105 | function deSelect() { 106 | var idsetd = charIDToTypeID( "setd" ); 107 | var desc889 = new ActionDescriptor(); 108 | var idnull = charIDToTypeID( "null" ); 109 | var ref51 = new ActionReference(); 110 | var idChnl = charIDToTypeID( "Chnl" ); 111 | var idfsel = charIDToTypeID( "fsel" ); 112 | ref51.putProperty( idChnl, idfsel ); 113 | desc889.putReference( idnull, ref51 ); 114 | var idT = charIDToTypeID( "T " ); 115 | var idOrdn = charIDToTypeID( "Ordn" ); 116 | var idNone = charIDToTypeID( "None" ); 117 | desc889.putEnumerated( idT, idOrdn, idNone ); 118 | executeAction( idsetd, desc889, DialogModes.NO ); 119 | } 120 | // delete layer 121 | function deleteLayer() { 122 | var idDlt = charIDToTypeID( "Dlt " ); 123 | var desc895 = new ActionDescriptor(); 124 | var idnull = charIDToTypeID( "null" ); 125 | var ref56 = new ActionReference(); 126 | var idLyr = charIDToTypeID( "Lyr " ); 127 | var idOrdn = charIDToTypeID( "Ordn" ); 128 | var idTrgt = charIDToTypeID( "Trgt" ); 129 | ref56.putEnumerated( idLyr, idOrdn, idTrgt ); 130 | desc895.putReference( idnull, ref56 ); 131 | var idLyrI = charIDToTypeID( "LyrI" ); 132 | var list17 = new ActionList(); 133 | list17.putInteger( 2 ); 134 | desc895.putList( idLyrI, list17 ); 135 | executeAction( idDlt, desc895, DialogModes.NO ); 136 | } 137 | // save file function 138 | function saveImageFile(file) { 139 | var idsave = charIDToTypeID( "save" ); 140 | var desc20 = new ActionDescriptor(); 141 | var idAs = charIDToTypeID( "As " ); 142 | var desc21 = new ActionDescriptor(); 143 | var idBytO = charIDToTypeID( "BytO" ); 144 | var idPltf = charIDToTypeID( "Pltf" ); 145 | var idIBMP = charIDToTypeID( "IBMP" ); 146 | desc21.putEnumerated( idBytO, idPltf, idIBMP ); 147 | var idLZWC = charIDToTypeID( "LZWC" ); 148 | desc21.putBoolean( idLZWC, true ); 149 | var idTIFF = charIDToTypeID( "TIFF" ); 150 | desc20.putObject( idAs, idTIFF, desc21 ); 151 | var idIn = charIDToTypeID( "In " ); 152 | desc20.putPath( idIn, file ); 153 | var idDocI = charIDToTypeID( "DocI" ); 154 | desc20.putInteger( idDocI, 195 ); 155 | var idsaveStage = stringIDToTypeID( "saveStage" ); 156 | var idsaveStageType = stringIDToTypeID( "saveStageType" ); 157 | var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" ); 158 | desc20.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded ); 159 | executeAction( idsave, desc20, DialogModes.NO ); 160 | } 161 | // run function 162 | function run(){ 163 | for (var i = 0; i < footageFiles.length; i++) { 164 | if (footageFiles[i] instanceof File){ 165 | openImageFile(footageFiles[i]); 166 | var footageDocument = app.activeDocument; 167 | var bgLayer = footageDocument.activeLayer.name; 168 | openImageFile(maskFiles[i]); 169 | var maskDocument = app.activeDocument; 170 | mergeDocuments(footageDocument.name); 171 | closeFile(); 172 | var maskLayer = footageDocument.activeLayer.name; 173 | selectMask(); 174 | selectLayer(bgLayer); 175 | contentAware(); 176 | selectLayer(maskLayer); 177 | deSelect(); 178 | deleteLayer(); 179 | var processedFolder = Folder(saveFolderPath); 180 | if (!processedFolder.exists) { 181 | processedFolder.create(); 182 | } 183 | saveImageFile(new File(saveFolderPath + "/ca_" +footageDocument.name)); 184 | closeFile(); 185 | } 186 | } 187 | alert("Processing done!"); 188 | } 189 | //var currentFolder = Folder.current; 190 | var footageFolder = Folder.selectDialog("Select source footage folder:"); 191 | var footageFolderPath = footageFolder.fsName.replace(/\\/g,'/') + "/"; 192 | var saveFolderPath = footageFolder.parent.fsName.replace(/\\/g,'/') + "/result"; 193 | var maskFolder = Folder.selectDialog("Select mask folder:"); 194 | var maskFolderPath = maskFolder.fsName.replace(/\\/g,'/') + "/"; 195 | var footageFiles = Folder(footageFolderPath).getFiles(); 196 | var maskFiles = Folder(maskFolderPath).getFiles(); 197 | run(); 198 | --------------------------------------------------------------------------------