• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

apply logo and suitable for different sizes

Advocate ,
Dec 09, 2017 Dec 09, 2017

Copy link to clipboard

Copied

Hello to all

I do not know if it is possible to do this

I have a folder on the desktop with the name watemark

inside this folder there are 2 png files

logo_white.png

logo_black.png

I would like when I have to apply one of these logos on an image

must be done automatically must be placed on the bottom left

must analyze the surface

if dark it applies the logo_white.png

if it is clear, apply logo_black.png

second passage

I use 3 SLRs with different mpx

nikon d700 has 12 mpx

nikon d610 has 24 mpx

nikon d800 has 36 mpx

I would like the logo that is applied to have the same dimensions

on all formats.

thank you

TOPICS
Actions and scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 09, 2017 Dec 09, 2017

You posted not enough informations, but I guess you just wanted to know is that possible you ask for.

Yes, it is, however I'm aware there are many (un)willing people here they could do it better and more accurately.

Anyway till anyone else propose his solution, you can try mine:

preferences.rulerUnits = Units.PIXELS

d = 20, m = 3, (h = (aD = activeDocument).height) > (w = aD.width) ? s = w : (s = h, d /= 2, m /= 1.5)

aD.selection.select([[(f = h / d), f * (d - m)], [m * f, f * (d - m)], [m * f, f * (

...

Votes

Translate

Translate
Adobe
LEGEND ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

- to be recognised as Mac user I removed exclamation mark from: !/w/.test($.os) and script worked the old way so, it didn't create shortcut.

- to see line I'm getting error at when function isn't rezognised I changed FSf to whatever else, like FFF (in the place function is called), I got error in line 45 and that's true, as when you look into code, function from line 1 is called from line 45 (not 25 like for you, what means you use different code, not that I posted)

- I looked into previous posts and found I posted 2017-12-11 17:16 special code that has 24 lines, but is not part of main code,

that was just special code wrote that you could place to one photo logos in all 9 spots 'at once'. Maybe you kept that code and combined somehow it with current one, it's why you get error at line 25 ?

- where do you keep your watermark folder with a script - in Photoshop folder or somewhere else?

- how do you run it, from ExtendScript ToolKit, from system, or from Photoshop?

- maybe you duplicated your script and have it in two places on disk?

Anyway make sure what code you use and as @JJMac suggested post it here so we find differences, as it seems you might not use exactly a code I posted. That's only a way to see it...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

after making the changes you suggested to me

when I start the script

it starts automatically in parallel desktop

the virtual machine where I installed windows

my question is this

there is another way to install the script with the watemark folder.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

You neither didn't asnwer for even one question nor posted your code So is it working now - you're not getting error anymore? Is all okey - you can run Watermark.jsx script with no problem? I mean mac version without creating shortcut?

- I don't have knowledge about virtual machine so I can't help. I can only point how to make script worked on Win and Mac.

- script can be placed anywhere on your comp (I guess). It must be placed in same 'Watermark' folder together with logos.

May you post your code, because still I don't understand some things there happen...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

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()   

 

     }  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

That is not code you should use. There are differences:

1) There is no #target photoshop

2) There is no exlamation mark in (/w/.test($.os)

3) There is .app extension instead of .exe

Item 1: running script from outside of Photoshop won't open it in Photoshop. So I guess you keep it in Photoshop Presets / Scripts folder and run directly from Photoshop.

Item 2: insert exclamation mark into code that it looks (!/w/.test($.os) so it's going to work on mac (of course without part that making shortcut)

Item 3: as far as you are on mac there can be whatever in 'else' statement (with correct syntax of course), so no matter what extension you used, but corect is .bat

I understand you want to run this code with making shortcut on mac. But forget about it. This code makes it only for Windows. I never had mac so I can't suggest anything to change. You don't need that code for making shortcut to keep your 'Watermark' folder (with script and logos) whereever you want, as IT CREATES SHORTCUT AT ONLY FIRST TIME YOU USE THIS SCRIPT. If you are on mac and don't want to keep Watermark folder (with script and logos) in Presets / Scripts folder then simply CREATE YOUR OWN SHORTCUT TO 'Watermark' folder MANUALLY. Script is doing it automatically, but it is only ONE TIME ACTION, so no need to rebuild script for mac's to work the same. Just create shortcut to 'Watermark' and save it in Presets folder.

Ah and don't forget to change last part of code you posted to correct version:

#target photoshop 

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.exe" '  + '"' + fN.fsName + '"\r\exit') 

     sys.close(), File('~/Desktop/sys.txt').rename('sys.bat') 

     File(String(sys).replace(/txt/, 'bat')).execute(), photoshop.quit() 

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 15, 2017 Dec 15, 2017

Copy link to clipboard

Copied

Kukurykus

I thank you for all the help you gave me

really very kind and helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

JJMack

your script is fine but can not detect if the background is light or dark.

Chuck Uebele

yours is very good and also does the batch that I prefer

but it does not detect the background

I must say that I use mac with photoshop cc2014

works well

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

You did not define what you mean by light or by dark of the size of the logo area or what to do if the area is average  not light or dark or the area is a checker board both light and dark.  IMO you need to detail better what you want done.   Scripting is powerful a good script need a well thought out design.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

JJMack

unfortunately I do not express well with English

I can use your script for other projects

that I have in mind

Thanks for all

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Though English is my native tong I do not do well.  English is harder than Photoshop.  I do not think I ever pass a English course in School growing up.  English is hard for me too.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 23, 2023 Oct 23, 2023

Copy link to clipboard

Copied

LATEST

OLD message but this script worked (after I changed the filepaths from / to \ for windows) - so thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines