10 Replies Latest reply on Apr 30, 2016 2:31 AM by c.pfaffenbichler

    Is this possible Live preview on script?

    natrev Level 3

      Hi Everyone!

       

      I have to apply Gaussian Blur on image using script. However I need to apply value and see the difference in live preview using script.

      Is this possible? Please find the screen shot for more details.

       

      Screen Shot 2016-04-28 at 9.36.21 am.png

        • 1. Re: Is this possible Live preview on script?
          c.pfaffenbichler Level 9

          Please explain the process you intend to Script and how the Gaussian Blur is supposed to be integrated in the larger operation.

          • 2. Re: Is this possible Live preview on script?
            natrev Level 3

            Hi Chris,

             

            Thanks for your reply. Please find the Code.

             

            var w = new Window ('dialog',"Apply Blur");
            w.add ('statictext {text: "Blur value"}');
            var value = w.add ('edittext {text: 0, characters: 3, justify: "center", active: true}');
            var slider = w.add ('slider {minvalue: 0, maxvalue: 100, value: 0}');
            slider.onChanging = function () {value.text = slider.value + 0.1}
            value.onChanging = function () {slider.value = Number (value.text) - 0.1}
            w.show();
            

             

            Apply blur on selected layer If I change the slider value lively.  Is this possible or suggest me any other alternate way.

            • 3. Re: Is this possible Live preview on script?
              c.pfaffenbichler Level 9

              Unless this is part of a larger dialog window I would recommend using the default dialog window.

               

              gaussianBlur();

              function gaussianBlur () {

              try {

              var idGsnB = charIDToTypeID( "GsnB" );

                  var desc4 = new ActionDescriptor();

              executeAction( idGsnB, undefined, DialogModes.ALL );

              } catch (e) {}

              };

              • 4. Re: Is this possible Live preview on script?
                natrev Level 3

                Hi Chris,

                 

                Thanks for the reply. I think you are wrongly understand my queries.

                I have to create one tool invoke the live preview update like glaussianBlur.

                 

                Code:

                var w = new Window ('dialog',"Apply Blur");  
                w.add ('statictext {text: "Blur value"}');  
                var value = w.add ('edittext {text: 0, characters: 3, justify: "center", active: true}');  
                var slider = w.add ('slider {minvalue: 0, maxvalue: 100, value: 0}');  
                slider.onChanging = function () {value.text = slider.value + 0.1}  
                value.onChanging = function () {slider.value = Number (value.text) - 0.1}  
                w.show();  
                

                 

                Screen Shot 2016-04-29 at 9.14.09 am.png

                Apply blur on selected layer If I increase the slider value lively.  Is this possible or suggest me any other alternate way.

                • 5. Re: Is this possible Live preview on script?
                  JJMack Most Valuable Participant

                  You may able to simulate a preview,  On a normal layer blur is a destructive process. You would not want to commit the blur till the user wanted to commit what the see.  To simulate a blur preview you would need complex on changing functions where you dupe the layer and blur the copy for the users to see. If they make additional adjustment you would delete the dupe make a new dupe and apply the blur for them to see. When they want to commit you would merge down the dupe and rename the layer to the original layer name

                  2 people found this helpful
                  • 6. Re: Is this possible Live preview on script?
                    c.pfaffenbichler Level 9

                    As JJMack pointed out one can »fake« it but there are problems.

                    An alternative to te dupe/delete approach might be using a Smart Object and editing the Smart Filter but again… problems.

                     

                    Why do you need to run a filter from a dialog really?

                    • 7. Re: Is this possible Live preview on script?
                      natrev Level 3

                      Thanks for your information Chris and JJMack,

                      @Chris, I need to know whether it is possible live preview on using script or not.

                      I have an idea to create small tool which is contains Blur, Add Noise and Sharpen filter, That's why I ask that queries.

                      Once again thanks for your valuable response and time.

                       

                      -yajiv

                      • 8. Re: Is this possible Live preview on script?
                        c.pfaffenbichler Level 9

                        Then I guess it is not properly possible with JavaScript alone (but there are work-arounds).

                        Maybe you should look into proper plugins written in C, C++, …

                        • 9. Re: Is this possible Live preview on script?
                          Tom Ruark Adobe Employee

                          Try an app.refresh(); after your executeAction for the gausiian blur and put the dialogs to .NO

                          1 person found this helpful
                          • 10. Re: Is this possible Live preview on script?
                            c.pfaffenbichler Level 9

                            But that still would necessitate either undoing before the next application or handling duplicates of the layer (as JJMack mentioned) or using Smart Filters to avoid applying a Filter again and again atop the already filtered layer.