8 Replies Latest reply on Apr 20, 2018 4:31 AM by AzatKhafizov

    Structure of "Brush Stroke" action for exporting to the script

    AzatKhafizov

      Hello everyone!

      After some search on the forums about Adobe Photoshop scripting I found that there is a problem of exporting "Use brush" (Brush Stroke) action to the JavaScript file.

       

      I tried on myself ActionFileToXML.jsx and ActionFileToJavascript.jsx from http://ps-scripts.sourceforge.net/xtools.html after recording some brush strokes via Action Palette, and Photoshop became "frozen".

      (When I used "Fill" tool without any brush strokes - saved action file converted without problem)

       

      I also tried Convert Actions File from http://www.tonton-pixel.com/scripts/utility-scripts/convert-actions-file/index.html . Result was the same.

      Without recording brush strokes .atn action file converts without problem, but if I try to export action file with recorded brush strokes application becomes "frozen".

       

      I tried to open converted files in the destination folder in hope that they will have brush strokes actions converted to the script - but there was FAIL. This did not happen.

       

      -----

       

      I did some research of this theme and found that .atn files can be viewed via Freeware Hex Editor XVI32 from http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm

      And I found that simple action file with commands Set Foreground Color (red) - Fill

      im002.JPG

      will become this:

      im001.JPG

       

      And another simple action file with commands Set Foreground Color (red) - Fill - Set Foreground Color (yellow) - Select brush - Set current brush - Use brush

      im003.JPG

      will become this:

      im004.JPG

      Please, pay your attention to the right scrollbar, file is really huge.

      Action Set - No Brush.atn takes only 1 KB, and Action Set - Brush.atn - 7 423 KB.

       

       

      I make assumption that this big data is about speed of drawing of the line, pressure of the pen on the tablet, direction of the drawing in each millisecond and so on.

       

       

      So my question - how to decode this data into the JavaScript? Maybe someone from you, dear users, knows how to operate with such low-level data for further scripting.

      In fact, Photoshop somehow understands .atn files and can play "Use brush" commands. So, the solution really exists!

       

      Could you help me, please?

        • 1. Re: Structure of "Brush Stroke" action for exporting to the script
          Davide_Barranca Adobe Community Professional

          Hi,

          you're getting the same results I got last time I tried a few years ago – a new interesting way to freeze photoshop

          I'm not personally aware of any way to reverse engineer brush strokes, to the best of my knowledge the format is not documented anywhere – but I will sit here patiently waiting for others to reply, it's a very interesting question indeed.

           

          Davide

          • 2. Re: Structure of "Brush Stroke" action for exporting to the script
            xbytor2 Level 4

            One thing you might want to try is to just let one of the conversion scripts run for an hour or so. I know that ActionFileToJavascript.jsx

            has this problem with embedded color profiles. It looked like PS was locked up. Instead, the script was just processing a lot of binary data which looks like it may be the case here.

             

            -X

            • 3. Re: Structure of "Brush Stroke" action for exporting to the script
              AzatKhafizov Level 1

              Davide_Barranca, xbytor2, thank you for your responses!

              I tried to run ActionFileToJavascript.jsx for converting of Action Set - Brush.atn to JavaScript file.

              I waited for 1,5 hours. Unfortunately, Photoshop did not come back alive and I killed the process in the Task Manager.

              Tonight I will try this operation again for about 5 hours.

               

              By the way, .atn files which I want to convert take about 11-15 GB each. So if there is such long process of conversion for 7,5 MB file, I really do not have time for conversion of the true big files.

               

              I continue to search for solution around the Internet.

              • 4. Re: Structure of "Brush Stroke" action for exporting to the script
                AzatKhafizov Level 1

                Hi!

                I tried to run ActionFileToJavascript.jsx for converting of Action Set - Brush.atn (7,5 MB) again. I waited for 8 hours and 20 minutes (I left computer to work while I was sleeping). Result is the same - "frozen" application and lack of the final converted file.

                 

                xbytor2, you said that ActionFileToJavascript.jsx has problem with embedded color profiles, which causes slow processing of the binary data. Could you explain problem a little bit further, please? Why do embedded color profiles cause slow speed of the operation?

                • 5. Re: Structure of "Brush Stroke" action for exporting to the script
                  xbytor2 Level 4

                  Embedded color profiles are large blocks of binary data as Brush Stroke Action likely is. Reading them from the file is easy enough, but it has to be converted into a form that can be used in an ActionDescriptor. The reverse happens when writing the data to disk as JavaScript. These conversions are time killers.

                   

                  One other thing that maybe happening is that it maybe crashing the JS interpreter (which I've done before) because of the large volume of the data being converted.

                  • 6. Re: Structure of "Brush Stroke" action for exporting to the script
                    AzatKhafizov Level 1

                    xbytor2, thank you for your answer!

                    And could you tell me, please, or give a link to the material, how "Brush Stroke" action should look in JavaScript?

                     

                    I got via ScriptListener.8li next code, when I selected Brush Tool:

                    var idtoolModalStateChanged = stringIDToTypeID( "toolModalStateChanged" );

                        var desc6 = new ActionDescriptor();

                        var idLvl = charIDToTypeID( "Lvl " );

                        desc6.putInteger( idLvl, 0 );

                        var idStte = charIDToTypeID( "Stte" );

                        var idStte = charIDToTypeID( "Stte" );

                        var idexit = stringIDToTypeID( "exit" );

                        desc6.putEnumerated( idStte, idStte, idexit );

                        var idTool = charIDToTypeID( "Tool" );

                            var desc7 = new ActionDescriptor();

                            var idIdnt = charIDToTypeID( "Idnt" );

                            desc7.putString( idIdnt, """pntb""" );

                            var idTtl = charIDToTypeID( "Ttl " );

                            desc7.putString( idTtl, """Brush Tool""" );

                        var idTool = charIDToTypeID( "Tool" );

                        desc6.putObject( idTool, idTool, desc7 );

                        var idKnd = charIDToTypeID( "Knd " );

                        var idKnd = charIDToTypeID( "Knd " );

                        var idPnt = charIDToTypeID( "Pnt " );

                        desc6.putEnumerated( idKnd, idKnd, idPnt );

                        var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

                        desc6.putBoolean( idkcanDispatchWhileModal, true );

                    executeAction( idtoolModalStateChanged, desc6, DialogModes.NO );

                     

                    Unfortunately, this script does not allow to record Brush Tool (Allow Tool Recording option in Actions menu becomes disabled and gray).

                    • 8. Re: Structure of "Brush Stroke" action for exporting to the script
                      AzatKhafizov Level 1

                      Kukurykus, thank you very much!!!