6 Replies Latest reply on Nov 1, 2015 10:48 AM by zvi_t

    Create text layer on click


      I'm not asking how to write this code, I'm asking if it's possible. If it is, I'll figure it out.


      Let me first explain what I do so you'll understand how the script I need can help me.

      I design digital wedding albums in Photoshop. My designs are not the classic boxes with white spaces all around (which would make it easy for any script to find the separate images) but some blend into each other and many are masked and under overlaying design elements.

      Now, in software like "Dg Foto", you can export a draft for client review where each image has a watermarked number on it so client can easily request "Please switch image 4 with image 6!"


      In general, what I want in the end is to have text layers over each image with lowered opacity (watermarked) for client review. I couldn't think of anyway to do this with an action since the layers are not consistent enough for an action to always work... layer names vary from project to project etc... so I am thinking maybe a script will help and here's how I think it can be done... As the script runs, I just would click where I want the number "1" to be created - and the script would create a text layer with the number "1" over the place I clicked. Then I would click somewhere else and a text layer with "2" would be created, again, under where I clicked... and so on and so forth until I'm done with all the images and somehow I'd stop the script.


      Do you see this as possible?

        • 1. Re: Create text layer on click
          dominique filiol Level 2

          Bonjour !


          try this :





          var doc = app.activeDocument;

          if (doc.layers.length > 1)


            i = doc.layers.length

            for(x=1; x <= i; x++)


                var calqueSel = doc.layers[i - x];

                calqueSelNom = calqueSel.name;

                Result = calqueSelNom.split(" ");

                if( Result[0]=="natural" && Result[1] == "environment" )


                  calqueSel.name = "environment_" + Result[3];




          • 2. Re: Create text layer on click
            JJMack Most Valuable Participant

            I think if you just added a centered watermark to all your proof imaged you would have no problem.  This could easily with a script. Add the texts layer centered over the image. Add a layer style to the text layer that sets the Fill 0 so the text layers pixels will not show.  All that will show are the style effects generated for the layer.  Here are a couple of watermark layers that have their layer style fill set to 0...


            This one with exif information opacity lowered to 35%



            • 3. Re: Create text layer on click
              dominique filiol Level 2

              Excuse me !
                for my error handling!

              • 4. Re: Create text layer on click
                zvi_t Level 1

                JJmack, I batch watermark images in Lightroom when needed. If this were a premiere pro or after effects project, this would be SO easy - just edit your watermarked footage and when you're ready to export the final album with no watermark, just REPLACE the "footage"! Problem is that photoshop doesn't reference the images to a file on the computer but rather copies the original image into the PSD file so you can't do that. Yes, you can use datasets but that's getting a little messy.


                i will try

                • 5. Re: Create text layer on click
                  zvi_t Level 1

                  What is in the third index of the array Result[3]?

                  • 6. Re: Create text layer on click
                    zvi_t Level 1

                    Also, i = doc.layers.length wouldn't work because not every layer is an image. There are many mask layers and vector layers that I don't need watermarks on. That's why I wanted to run a script based on a mouse click and mouse coordinates. Deep down I feel it's possible because the Album Design 6 software does EVERYTHING via scripting of photoshop so I know a script should be able to be triggered on a mouse click.