5 Replies Latest reply on Jan 27, 2017 3:19 AM by Stephen_A_Marsh

    Auto saving hundreds of picture-in-picture batch/script help!?

    Ronnie190

      Hello All! Long time Adobe fan here. First post, too. Nice to meet ya in advance.

       

      So, I'm working on a very specific project. I'd like to create an animation from a few thousand .png images. It's going to wind being used by a system that only reads images and flips through them at a speed user determined. Like a flip book really. I have already created what I THOUGHT would work perfectly, but alas, the reader is picky. So, I have thousands of images that are the wrong size.

       

      This is what I have:

      1)  NewBackground.png

      2)  Oldpic0001.png ....   Oldpic4000.png

       

      I'd like to know how to set up a batch/script to simply place Oldpic#.png on top of NewBackground.png, scale to fit the border on the left and right (portrait), then center horizontally and vertically, and finally save with a incremental file name that begins with whatever0001.png (the most important factor that the numbers always showing to the thousandths place regardless if the number has reached that point.

       

      Please tell me you know something I haven't been able to find an answer anywhere.

        • 1. Re: Auto saving hundreds of picture-in-picture batch/script help!?
          Stephen_A_Marsh Adobe Community Professional

          Sure, one way to do this is with an action and the batch automate command:

           

          Action contents:

           

          atn.png

           

          File > Automate > Batch setup:

           

          batch.png

           

          Results:

           

          result.png

           

          background = common background image

          oldpics = old pics

          newpics = output of batch action combining oldpics + background

           

           

          Notes:

           

          1) The action needs to place the common background image file, however as the background is being placed into the oldpic document, the old pic document was assumed to be the same canvas size as the background. This assumption may not be correct.

           

          2) The action makes use of a script to resize the selected layer content to a target pixel width, assuming that the source content may vary in width. This may not be required if you have a consistent source/target value and a standard transform/resize would work.

           

          3) The resize script works from the centre and the placed layer is centred, however I added the align steps to centre to demonstrate anyway, even if redundant.

           

          This was all very much rough and ready and done in 15 minutes, it could likely be done better with more forethought and planning.

           

          Script:

           

          // https://forums.adobe.com/thread/988084
          #target photoshop 
          function main(){ 
          if(!documents.length) return; 
          var startRulerUnits = app.preferences.rulerUnits; 
          app.preferences.rulerUnits = Units.PIXELS; 
          var doc = activeDocument; 
          var res= doc.resolution; 
          var LB = activeDocument.activeLayer.bounds; 
          var Width= LB[2].value - LB[0].value; 
          var onePix = 100/Width; 
          var newSize = onePix * 450; 
          doc.activeLayer.resize( newSize , newSize, AnchorPosition.MIDDLECENTER); 
          app.preferences.rulerUnits = startRulerUnits; 
          } 
          main();
          

           

          Change line 12’s value of 450 to the desired pixel width.

           

          Without sample files it is hard to comment with specifics, however everything worked in my tests using the assumptions based on my dummy test files.

           

          Let me know if you need any help!

          1 person found this helpful
          • 2. Re: Auto saving hundreds of picture-in-picture batch/script help!?
            JJMack Most Valuable Participant

            If you know JavsScript there a Photoshop Scripting forum you can ask for help in when you write your script and have some problem.Actions can not use logic so you will not be able to do you job batching an Action. The Image Processor and Image Processor Pro scripts are for batching image and outputting many more image file.  The Script Load Files into a stack will open all you image into a single document as layers. It has a option to try to align images but has no scaling options. Photoshop has a 8,000 layers limit.  You will need to write your own custom script or heir a programmer to code one for you. You should design the process well before you start to code. Photoshop Scripting

            • 3. Re: Auto saving hundreds of picture-in-picture batch/script help!?
              Ronnie190 Level 1

              Wow incredible answers! Your method will prove to be useful while the degree of complexity of my project grows.

               

              A little while after I asked this forum (of which I intend to become a regular contributor to), I found a dumb-geniouses kind of way. Your method is much more useful in a lot of degrees.

               

              I recorded just 2 actions:

              I had to decrease Oldpic.png image size with its ratio linked down to the 720px wide.

              And then I increased its canvas size centered around the .png to the hight of 1080px I needed, filling the difference in with the color it was already surrounded with.

               

              After then it was merely a point of selecting 4 number points as the file name in the batch processor and holding the extension.

               

              Gave myself a little pat on the back, too.

               

              Of course it turned out to be a misinterpretation on my part because it needed to be .jpg. I'm more of a dev than a designer so that was a quick ren *.* *.jpg in the ol command prompt and voila.

               

              Darn thing still hasn't loaded correctly as the boot animation for my Virtual Machine. That's probably a wholy different forum though.

               

              Thanks for taking tine out of your day to educate me! I will definitly be needing what you've shown me. I've already fashioned some future ideas based off of your answer!

              • 4. Re: Auto saving hundreds of picture-in-picture batch/script help!?
                Ronnie190 Level 1

                I also got a huge kick that you named the project "whatever0001.png". I really appreciate your customized response! I sent a screenshot to the other devs on the project. You just don't get that kind of detail from other discussion boards.

                • 5. Re: Auto saving hundreds of picture-in-picture batch/script help!?
                  Stephen_A_Marsh Adobe Community Professional

                  Glad to be of help, if a specific step or process needs to be explained in more detail, just let me know.