13 Replies Latest reply on Dec 12, 2011 12:02 PM by AIF Bob

    PixelBender + Flash in Photoshop panel

    DavideBarranca Level 1
      Dear all,
      I've posted something similar in Configurator forum with no luck, so here I am with my question: any hint or comment will be greatly appreciated.

      Is it possible for a SWF that contains a PixelBender shader to be embedded in a Photoshop CS4 panel?

      I'd like to exploit some built-in function of Flash (like blur and other filters) without the need to write custom code, and build a complex PixelBender shader concatenating several pbj files: the Photoshop panel should contain only the sliders of course, and the effect have to be applied to the opened image. The Photoshop panel developer's guide explains that, for the project to be working and besides the swf, it's needed a javascript that communicate with Photoshop through its DOM, and it seems that there happens all the Photoshop commands. Currently I'm stuck and it seems to me there's no way to make it works.

      Why all this pain? Because it would mean to be able to have complex shaders in form of sort-of-binary plugin-like easy to use Photoshop panel; it would open a world of wonders.
      Thanks in advance for any comment or thoughts

      Davide Barranca
      Bologna, Italy
        • 1. Re: PixelBender + Flash in Photoshop panel
          Kevin Goldsmith Level 3
          You want to use a Pixel Bender filter embedded in a SWF to process images in Photoshop? You don't have to do anything so complicated. You can use the Pixel Bender plug-in for Photoshop from Adobe Labs and use Pixel Bender Kernels and Pixel Bender Graph files (Pixel Bender Graphs allow you to string together multiple filters).

          You can get the plug-in from: http://labs.adobe.com/technologies/pixelbender/

          Are you in Milan for Max? If so, I can discuss this with you in person.

          • 2. Re: PixelBender + Flash in Photoshop panel
            DavideBarranca Level 1
            Ciao Kevin,
            sadly I won't be able to meet you in Milan...!!
            Actually my workflow is a bit more complicated than I described, because I'm using Lacquer Conduit to make easily the PBJs (nevertheless to connect them writing my own code will be a little pain in the neck). I'm already using and having fun with PixelBender Toolkit, but, at least until someone will put in the Exchange some basic filters (Minimum, Maximum, Gaussian Blur) that I can use as building blocks for composing more elaborated workflow, I can't afford (or I'm not enough skilled, maybe) to write from scratch all the pieces I need. So, for instance, Flash gaussian blur filter would simplify a lot. I was really interested in the possibility of doing that weird importing...

            Any plan for PixelBender Graph to import PBJ in Photoshop PB Gallery?


            Davide Barranca
            Bologna, Italy
            • 3. Re: PixelBender + Flash in Photoshop panel
              The answer to your first question is Yes. You can definitely use a SWF that contains a PixelBender shader as a Photoshop Panel. All you have to do is copy the SWF to Adobe Photoshop CS4/Plug-ins/Panels. John Nack has a bit more about this on his blog.

              The only thing to be careful of is where the .pbj file resides. If you are using an URLRequest/URLLoader to acquire the binary pbj data, you will need to copy it into the panels directory or somewhere known. Your best bet, however, is to embed the pbj data into the SWF using the Embed keyword like the following example:

              [Embed(source="myFilter.pbj", mimeType="application/octet-stream")]
              var MyFilterData:Class;

              If you decide to go this route and you are using Flash CS4, you will need to download the Flex 3.2 SDK somewhere to your harddrive and direct Flash CS4 to it. If you are already using flex, you don't need to do anything.

              Were you having any trouble getting the Panels with Pixel Bender scripts working? I just tried it on my machine, and it worked for a simple example. I think the most difficulty will be around the interface between the SWF and Photoshop, but John's blog addresses this.

              I'm not certain whether or when we'll have a pbj runtime integrated into the Photoshop plug-in; however, this is a very common request from the community, and we are definitely hearing the need for it.

              • 4. Re: PixelBender + Flash in Photoshop panel
                DavideBarranca Level 1
                Dear Brian,
                such a good news! Thank you very much for your answer.
                I'm using Flex sdk with a code borrowed from Mike Chambers post, but surely I'm doing something wrong (and that's very easy since my programming skills are poor - for instance I don't know how to get rid of his image.jpg loading code). Could you gently show the needed code you used for your example?
                Thanks again,

                Davide Barranca
                Bologna, Italy
                • 5. Re: PixelBender + Flash in Photoshop panel
                  BrianRonan Level 1
                  Hi Davide,

                  I'm not sure the sample I ran would help you much since it's very much like Mike's example in that it opens an existing image and applies a Pixel Bender filter to it. Additionally, the source is a .fla file. I'll see if I can get together a Flex example tomorrow, but I wanted to clarify somethings first.

                  Are you having trouble with Mike's tutorial directly, or are you having trouble integrating that filter into Photoshop? In other words, are you able to run the SWF on its own as a standalone?
                  • 6. Re: PixelBender + Flash in Photoshop panel
                    DavideBarranca Level 1
                    Dear Brian,
                    I've used successfully the code from Lee Brimelow's video tutorial (that's the one that Mike Chamber tweaked). The problem is that my Photoshop panel contains the picture loaded from the code (and not the one opened in the program) with the effect pre-setted, and not the slider only (that should apply the effect to the opened picture in Photoshop) Probably I'm also having problems with the code related to the CSXS class...
                    Again, thanks for your help,

                    Davide Barranca
                    • 7. Re: PixelBender + Flash in Photoshop panel
                      BrianRonan Level 1
                      Hi Davide,

                      I have to apologize. I misread your first email and misunderstood what you were trying to achieve. I thought you were simply asking whether you could use Pixel Bender filters in the Panels at all (the answer to which I didn't know until I tried it yesterday). I see now that you are trying to write your own Photoshop filter with the Panel APIs.

                      I'm not sure what you want to achieve is possible with the current Photoshop panel model, and even if it is possible, I don't think it will be very fast. The Photoshop Panel functionality is to provide an easy way to add a new workflow UI to Photoshop, but I don't think it was intended to add new image processing features to Photoshop. In general, if you are adding any new image processing to Photoshop, you have to go through the Photoshop Plug-in SDK. I did look at the documentation for the Panel API. I'm no expert on Photoshop scripting, but it looks like the exported properties of the DOM are purely descriptive with little chance to access the actual data. The only bit of promise is to use the ColorSampler tool to pull the image data from the foreground window, but that would be extremely painful and very slow. Even if that did work, I didn't see any way to actually update the pixels in the document.

                      That being said, I believe there might be an indirect way to achieve what you are trying to do. The basic workflow would be:

                      1. Use Panel API + Javascript to have Photoshop write out the image to a known location
                      2. Load the image from the saved location in the SWF
                      3. Process the image in the SWF
                      4. Save the resultant image back out to the file
                      5. Use the Panel API + Javascript to have Photoshop load the file

                      I'm not 100% sure that this will work, and it definitely does have some side effects like leaving an image on disk and opening up another document in Photoshop for the results. But, I believe it will do the job. I'll see if I can whip up a tutorial on this if it works, but since it is not an easy example, it might take some time.

                      As I said, I'm definitely no expert on Photoshop scripting, so I would strongly recommend contacting the Photoshop scripting forums to see if there is a way acquire the image data directly from the DOM. Judging from what the Panel API is trying to achieve, it's not likely that this is possible or will be well supported. Trying to track down the pbk versions of the filters to put into the Pixel Bender Photoshop Plug-in is always an option.

                      Again, I apologize for the misunderstanding. My eyes simply stuck to the question in bold. Good luck with your search.

                      • 8. Re: PixelBender + Flash in Photoshop panel
                        BrianRonan Level 1
                        FYI, it looks like the potential workaround plans have been foiled. I've tried to whip up a sample, but I've hit a roadblock with step 4.

                        We can achieve steps 1-3, and 5, but step 4 is going to be trouble since the Panel API doesn't support AIR applications - and the AIR ActionScript Runtime is the only way to write files to the harddrive (that is unless someone on these forums is more clever). So, it looks like you might not be able to do what you were intending to after all without some kind of change to either the plug-in or the panel APIs.

                        Again, sorry for the misunderstanding. Let me know if you get any traction on accessing the image data for the foremost document on the scripting forums. Best of luck!
                        • 9. Re: PixelBender + Flash in Photoshop panel
                          DavideBarranca Level 1
                          Dear Brian,
                          first let me thank you very much for your test and info, I really appreciated them.
                          Can I ask you whether you think that PatchPanel could be a step in the right direction? Sorry if this looks like a dummy question, but before starting to dig deeper in a programming language/environement, I'd like to be sure it's the right way - do I look like one that's avoiding Photoshop SDK like pests, don't I? ;-) The fact is that I see a lot of new emerging possibilities that seems more appealing (to a ignorant like me) than SDK, so any (personal of professional) comment from you is as usual really appreciated. Thanks again,
                          • 10. Re: PixelBender + Flash in Photoshop panel
                            Joe ... Ward Level 4
                            The Flash FileReference now has a save() function that can write to the local disk, so AIR no longer has a monopoly on disk access.
                            • 11. Re: PixelBender + Flash in Photoshop panel
                              BrianRonan Level 1

                              Thanks for the information! It's weird that the method is not listed in the ActionScript 3.0 Reference. This is a great tidbit.


                              As I read the purpose of PatchPanel, it doesn't seem like it was originally intended to work like the other image processing plug-ins. It looks like the model is about a different way to provide new workflows and automation UI using Flash. Because of this, fitting a filter style plug-in technology piece into this model will have its drawbacks. For instance, the method I described above, though possible (Thanks again Joe!), will have it's side effects, namely the creation of extra files on the harddrive and the requirement for user input when saving the file from the SWF.

                              That being said, a sign of a good API or utility is that people will use it in ways you never dreamed. I would not want to stifle that, so I would say that it's worth a try if your business need deems it worthy. You might want to talk to the Patch Panel and Photoshop community directly to see if this is a potential growth area or one that might receive better support in the future.
                              • 12. Re: PixelBender + Flash in Photoshop panel
                                Royi A Level 1

                                You say there's no way to retrieve a certain layer in Photoshop as array in AS to be manipulated (Using PB, AS3 and ExtendScript) and then written back into the layer in Photoshop?

                                • 13. Re: PixelBender + Flash in Photoshop panel
                                  AIF Bob Level 3

                                  Royi A wrote:


                                  You say there's no way to retrieve a certain layer in Photoshop as array in AS to be manipulated (Using PB, AS3 and ExtendScript) and then written back into the layer in Photoshop?


                                  Are you talking about doing this using a plugin to Photoshop or using the PatchPanel API? You might have to check with the Photoshop people about whether it's possible to interface with Flash from PatchPanel.