10 Replies Latest reply on Dec 5, 2017 8:38 PM by JJMack

    Watermark Script

    benjamink78098692

      Hi! I am in Photoshop now and would like to make an script for placing watermarks so that they take up 10% of the width of the image and are placed so that they are 3% in from the left and 3% from the bottom on the canvas. How do I do this?

        • 1. Re: Watermark Script
          JJMack Most Valuable Participant

          It should be easy to modify the script I have posted it places the watermark on the bottom right not the left.  You would need to change the last transform..

           

          #target photoshop;  
          app.bringToFront();  
          var logoFile = "~/Desktop/JJMack.png"; // Watermark file should be large for resize down works better than up
          var LogoSize = 10; // percent of document height to resize Watermark to
          var LogoMargin = 1;                                         // percent of Document height the Watermark should have as a margin
          
          
          placeWatermark(logoFile, LogoSize, LogoMargin);             // Place Watermark  into the bottom right of document
          
          
          function placeWatermark(Image,Size,Margin){  
            if(!documents.length) return;   // if no document return
            try{  
            var doc = app.activeDocument; // set Doc object to active document
            app.displayDialogs = DialogModes.NO; // Dialog off 
            var strtRulerUnits = app.preferences.rulerUnits; // Save Users ruler units 
            var strtTypeUnits = app.preferences.typeUnits; // Save Users Type units 
            app.preferences.rulerUnits = Units.PIXELS; // work with pixels 
            app.preferences.typeUnits = TypeUnits.PIXELS; // work with pixels 
            var fileObj = new File(Image);                 // the passed file
            if(!fileObj.exists){   // If file does not exits tell user 
            alert(fileObj.name  + " does not exist!");  
            return;  
            }  
            placeFile(fileObj); // Place in file the Watermark png file
            activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER); // Insure Place did not scale layer  
            var SB = activeDocument.activeLayer.bounds; // get layers bounds 
            var layerHeight = SB[3] - SB[1]; // get layers height  
            var resizePercent = (100/layerHeight)*(Size/100*doc.height.value); // Percent to resize by 
            activeDocument.activeLayer.resize(resizePercent ,resizePercent,AnchorPosition.MIDDLECENTER);  // Resize width and height by percentage 
            SB = activeDocument.activeLayer.bounds; // get resized layers bounds  
            activeDocument.activeLayer.translate(-SB[0].value,-SB[1].value); // Move resized layer to top left canvas corner 
            var LayerWidth = (SB[2].value - SB[0].value);  
            var LayerHeight = (SB[3].value - SB[1].value);  
            marginSize = Margin/100*doc.height.value; // move resized watermark into the document lower right corner with some margin
            activeDocument.activeLayer.translate((doc.width.value -marginSize - LayerWidth),( doc.height.value -marginSize - LayerHeight));
            }
            catch(e) { alert(e + ': on line ' + e.line); } // inform user of error  
            finally{  
            app.preferences.rulerUnits = strtRulerUnits; // Restore user ruler units  
            app.preferences.typeUnits = strtTypeUnits; // Restore user type units    
            };  
          }; 
          
          function placeFile(placeFile) {  
              var desc21 = new ActionDescriptor();  
              desc21.putPath( charIDToTypeID('null'), new File(placeFile) );  
              desc21.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );  
              var desc22 = new ActionDescriptor();  
              desc22.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 );  
              desc22.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 );  
              desc21.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc22 );  
              executeAction( charIDToTypeID('Plc '), desc21, DialogModes.NO );  
          };  
          
          1 person found this helpful
          • 2. Re: Watermark Script
            benjamink78098692 Level 1

            Do you know if I could use a psd or ai file instead of the png so that it will come in with layers?

            • 3. Re: Watermark Script
              JJMack Most Valuable Participant

              You can use any image file type you want the watermark layer will be a single smart object layer.  The Laye embedded object can be a layered file like PSD , PSB or TIFF.  If  it is you can open the embedded object is Photoshop.  The disadvantage is the Layered embedded file will be larger then a flat file like png.  This will just make your watermark layered image file size  larger than need. IMO the no good reason to have a layered smart object.  You can of still have your Logo master file a layer file to make ir easy to update. IMO you should save a png file as well as your PSD and watermark using the PNG file not the layered file.

              • 4. Re: Watermark Script
                matthews63743827

                Is there a way of modifying this script so that it embeds the smart object after placing it?

                 

                Thanks!

                Mat

                • 5. Re: Watermark Script
                  JJMack Most Valuable Participant

                  The way place works is it uses your file full resolution to render Pixels for you new Photoshop layer.  By default Place will create a smart object layer.  The layes's object will either contain a copy of your file or a link to your file.  The rendered layer pixels can not be changed with Photoshop tools like paint brush, erases etc.  There composite can be adjusted via smart filters. Also every Smart Object layer has an associated transform.  To scale and position the layer composite in you document.   Any time you change a smart object layers transform.  The transform is transforming the Pixels rendered for the layer. These pixels can not be changed by Photoshop tools.  The only want to change these is to open the layers object and modifying the object.  When you update the object Photoshop will render a new set of Pixels for the updated object.

                   

                  The way the script is coded your full size file is embedded in the layers object.   You would need to change the script if you want the layer to have a linked master watermark file which make not sense if you will be saving files for the web.  They are not layered and contain no objects.. 

                  • 6. Re: Watermark Script
                    matthews63743827 Level 1

                    Oh okay. I assumed the file was added as a linked smart object that could be broken.  One more question: I can't seem to figure out how to make the logo show up on the bottom left rather than bottom right.  Is there a line of code I need to modify or add?

                     

                    Also, how easy is it to alter this script to work in Illustrator?  A completely new script?

                     

                    Thanks!

                    Mat

                    • 7. Re: Watermark Script
                      JJMack Most Valuable Participant

                      I posted two version of the script here is a link to the one you want.  Right click the link and] save the script. The formatting should look better; You change the statement

                      var BottomLetf = false// false = Bottom Right true Bottom Left

                      Looks like Jive has changed again you man nee to uset the link and then right click save as in the page..

                      http://www.mouseprints.net/old/dpr/PlaceWatermark.jsx

                      1 person found this helpful
                      • 8. Re: Watermark Script
                        matthews63743827 Level 1

                        Thanks!

                        • 9. Re: Watermark Script
                          Chuck Uebele Adobe Community Professional & MVP

                          As far as Illustrator, you would need to write a new script. They're not interchangeable.

                          • 10. Re: Watermark Script
                            JJMack Most Valuable Participant

                            I do not use Illustrator one complex Adobe application is all I want.  

                             

                            If you use Illustrator I would expect that you would create your Watermark using all vector graphics in Illustrator and use that File as placed vector smart object in Photoshop.   Photoshop treats placed .AI and .SVG file as vector smart object to a point. I find that Rotation and perspective transforming is not supported with these vector smart objects.  I only hack a scripting Photoshop.

                             

                            I don't use the bridge much so I doe not try scripting the Bridge.  If you are automating an application via a script.  The script would need to be programmed for the application being automated. Illustrator is Adobe Vector editing application.  Photoshop supports some vector tools but is basically a pixels editor.

                             

                            I have read that Photoshop Pen tool is different then Illustrator's Pen tool.

                             

                            I do not even load Lightroom for I do not particulary want two  RAW UI and a lightroom user need to use ACR UI in Photoshop and Lightrool RAW conversion are open into Photoshop through ACR for Lightroom Develope module is not also a Plug-in like ACR. Several Adobe Applications use ACR however Lightroom does not. Lightroom user ACR in Photoshop and Lightroon can noy use Layers.  Only a composite layer can be use from Photoshop in lightroom so when you edit a document from lightroom in Photoshop Lightroom can no longer readjust its RAW conversion for conversion has been merged into the Photoshop's edits....  So I do not install Lightroom to keep things simple.  

                             

                            Change is not always better IMO.