Skip to main content
October 1, 2013
Question

About progress bar and Photoshop

  • October 1, 2013
  • 1 reply
  • 6233 views

I have been reading a lot about how to make a progress bar in photoshop (scripting) and my conclusion is that it is not worthy. The only way to make a progress bar is by using Palette window but Photoshop does not support it. If we use a dialog window, since it is modal, it will freeze whatever your script is doing so, you cannot use it (how to track the progress of a script if the script is paused while the dialog is being shown?). Although Photoshop does not support Palette, there are two workarounds that would make it work and they are using either app.refresh() or waitForRedraw() (and undocumented function that seems to me to do exactly the same thing that app.refresh() does). But as the manual says, app.refresh() will slow down considerably your code. According to my experimentation, each time you call app-refresh(), your script will waste about 1 second (no matter how powerful your computer is). That is a lot of time! In practical terms, you would use app.refresh() only a few times so your progress bar could be refreshed only a few times during the whole duration of your script, still one second lost for each time you use it. In other words, there is no good way of making a progress bar in photoshop scripting.

My question is: am I right? Is there a way to code a progress bar in PS that would not delay the code unreasonably?

This topic has been closed for replies.

1 reply

October 11, 2013

Just a follow up to my post above.

I ended up giving up the approach I was taking, that was to use the DOM. Too slow. It was taking one minute to process each image. Although I could live with that, I wanted something better, if it existed.

After reading and studying a lot the way of Action Manager, I managed to do the same thing using AM and now the progress bar is not necessary anymore. AM is too fast to need a progress bar!

Cheers.

DBarranca
Legend
October 11, 2013

Hi,

palette windows aren't supported in PS since they close as soon as the code is done with them - i.e. you can't show a palette as you'd do with a dialog, waiting for the user to interact with them as modeless windows.

The app.refresh() / waitForRedraw() workaround is "broken" on CC (I use quotes because it was not supposed to work, but did anyway on CS6 and former versions).

Yet..

If you want to implement Palettes in Photoshop now the only reliable way is via BridgeTalk, as shown here. A bit weird because it's PS that sends a message to itself, but it works.

That said I've always used ProgressBars either inside 'dialog' windows or using disposable 'palette' windows - if there's a slowdown, I've never found it unacceptable.

Davide Barranca

www.davidebarranca.com

October 11, 2013

Hi,

Thank you for the reply.

During my research on Photoshop script (I had never coded anything in PS script until around 2 weeks ago but I have a good experience with VBA and other languages which helps) I had found your page but I didn't want to follow your method first because BridgeTalk is a total stranger to me and secondly because in the last paragraph of that article, you write "since in a quite complex project I’m spending my time on (which started way before I knew about this technique), I’m still unable to make it work. The debugging is… quite complicate!".

My project is not complicated but still, considering my level of expertise, I am pretty sure it would take some time for me to get comfortable with it. Thanks anyway for the direction.

The main reason I gave up on using the progress bar was not the progress bar itself but the overall extreme slow speed of the DOM. The DOM hates recursion, hates going through layers and selecting them, etc. I'd say that from the one minute that it was taking to process an image (my file has around 300 layers), around 10 seconds was due to the implementation of the progress bar, so it was not the biggest culprit. The DOM itself is the problem.

What I am doing is re-writing everything (the routine using the DOM is done and does well what I want but it's slow) but using AM. I have learned enough about it (mostly from the people at ps-scripts.com), learned all the commands that I need in that weird AM style and I am blown away by its speed. Basically I do all I need using only AM commands, avoiding - when possible - to select layers to do work on them, until the last minute. I am not finished yet and I have no final measure but as far as I can foresee, I will be able to cut that one minute time to mere seconds, probably less than 5. It is really fast, as expected actually from good programming.

So, I place now very low priority into the progress bar. And if I have to learn even more complicated stuff to make it worthy, I will probably pass.