This is the code I use I hope I did not do something wrong function FSf(sF, dst, i) { if (sF && !dst.length) { Folder(dst[0] = sF.parent + '/' + (nme2 = (nme1 = decodeURI(sF.name)) + ' Logo')).create() } function gF(v) {return Folder(sF).getFiles(RegExp(v + '[^\.]+$'))} for(sF = gF('^').concat(gF('\\.')); i < sF.length; i++) { if (r1 = 'decodeURI(sF', r2 =').replace(RegExp(nme1), nme2)', sF instanceof Folder) { dst.push(eval(r1 + r2)); Folder(File(dst[dst.length - 1])).create(), FSf(sF, dst, 0) } if (/\.(jpg|psd)$/i.test(sF.name)) { displayDialogs = DialogModes.NO, preferences.rulerUnits = Units.PIXELS, open(sF) s = .75, hw = (h = (aD = activeDocument).height); if (h > (w = aD.width)) s = 0, hw = w obj = { tL: [1.5 - s, 1], tC: [7, 1], tR: [12.5 + s, 1], mL: [1.5 - s, 7], mC: [7, 7], mR: [12.5 + s, 7], bL: [1.5 - s, 13], bC: [7, 13], bR: [12.5 + s, 13] } function pos(v) { w1 = v[0], w2 = w1 + 1, h1 = v[1], h2 = h1 + 1, aD.selection.select ([[w * w1, h * h1], [w * w2, h * h1], [w * w2, h * h2], [w * w1, h * h2]]) } function wh(v) {return v / 15} w = wh(w), h = wh(h), pos(obj.bL) function loop(v1, v2) {for(j = v1; j < v2; j++) v1+= hst ; return v1} blk = loop(0, l2 = (l1 = (hst = aD.histogram).length) / 2), wht = loop(l2, l1) open(File(File($.fileName).path + '/logo_' + (blk >= wht ? 'white' : 'black') + '.png')), (log = activeDocument).resizeImage(hw / 7.5), (sel = log.selection).selectAll(), sel.copy() log.close(dnsc = SaveOptions.DONOTSAVECHANGES), aD.paste(), (jpg = new JPEGSaveOptions()) .quality = 12, aD.saveAs(File(dst[dst.length - 1].match(eval(r1 + '.path' + r2) .replace(/([\$\+\(\[\^])/g, '\\$1')) + '/' + sF.name), jpg), aD.close(dnsc) } } } function SYS(v) {return File(Folder.desktop + '/sys.' + v)} sys = SYS('txt'), bat = SYS('bat') if (/w/.test($.os) || Folder(prst = (strt = Folder.startup) + '/presets').getFiles('watermark').length) { bat.remove(), FSf(Folder.selectDialog('Please select top level folder'), [], 0) } else { File(prst + '/watermark').createAlias(fN = File($.fileName)) sys.open('w'), sys.write('ping 127.0.0.1 -n 2 > nul\r\start "' + strt.fsName + '\\photoshop.app" ' + '"' + fN.fsName + '"\r\exit') sys.close() File('~/Desktop/sys.txt').rename('sys.bat') File(String(sys).replace(/txt/, 'bat')).execute(), photoshop.quit() }
... View more