Subscripts?

Moderator: jsachs

Post Reply
Robert Schleif
Posts: 340
Joined: May 1st, 2009, 8:28 pm

Subscripts?

Post by Robert Schleif »

Within the constraints imposed by the existing structure of PWP, is there a way that "subscripts" might be implemented? A subscript would be a script that defines a contiguous series of transformations that has been saved out of a longer series of transformations. For example, a "B&W" subscript for me might be the following: Brightness Curve (to enhance contrast), Saturation, Monochrome, Brightness Curve (now used with a mask to adjust portions of the image). Thus, inserting my B&W subscript, (by choosing Edit, Insert subscript, and picking my B&W script) after an image would insert the four transformations with their settings. Possibly a subscript capability could be combined with the current capability for creating generic scripts, whose use is somewhat counterintuitive to me.
jsachs
Posts: 4218
Joined: January 22nd, 2009, 11:03 pm

Re: Subscripts?

Post by jsachs »

I explored this as an experimental feature last year but abandoned it after a couple of weeks of work as more and more complications arose, especially around passing multiple arguments to script subroutines. Instead, this feature is implemented already -- see the last topic in the help file for scripts: Creating Generic Scripts with Convert to Copy which I assume is what you are referring to. Another option is to load a script without clearing out the workspace and then copying the transformations you want.
Jonathan Sachs
Digital Light & Color
Robert Schleif
Posts: 340
Joined: May 1st, 2009, 8:28 pm

Re: Subscripts?

Post by Robert Schleif »

In that last section of Scripts, which deals with generic scripts, would it be possible to include an example and not to use the word "Load"? Because I don't know what Load means in this context, I've never tried to make and use a generic script.

Instead of trying to create a universal "Paste Subscript" capability, would it be possible to provide for this capability under certain prescribed and limiting conditions? For example involving only transformations whose only inputs are the preceding transformation and a workspace script is not being saved? (I have not yet found a need for the workspace scripts, and I don't explicitly use them.)

If it becomes possible to save and invoke subscripts, I imagine that they would be quite useful, sort of like plugins, but plugins where you have access to all the internal machinery if you want.
jsachs
Posts: 4218
Joined: January 22nd, 2009, 11:03 pm

Re: Subscripts?

Post by jsachs »

I will take another look at subscripts. In the meantime I added an example of generic scripts to the end of the Scripts.pdf document for the next release.
Jonathan Sachs
Digital Light & Color
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Subscripts?

Post by tomczak »

Have you tried Edit/Convert to Copy functionality? That works similar to the subscripts that you described.

For example, once you create your B&W script, use Convert to Copy before you save it (either as a script with the last transformation being current when you save it, or as a workspace script, in which case it doesn't matter which transformation is current). This is your subscript that you can reuse by 'inserting' it into other scripts that you create.

All you need to do is to load (reopen) this (sub)script, without closing your main script you're working on. The subscript will open as a new top-level branch, with Copy transformation on top. If you click on this Copy transformation, it will allow you to choose any output image from your main script branch (e.g. the last one). The main branch script will execute and then continue to Copy transformation and downstream from it.

Copy transformation is a top-level one, so you can't just add in below the last transformation in your main branch, but this is just a visual issue: the Copy transformation will continue the execution of your main script, just on the side of it, in its own branch.

This is actually quite flexible since you can have several branches starting with Copy transformation (each being one of your subroutines) and each of those branches can start executing from an output of any other transformation in the browser, providing that there are no circular references present. In effect, you can chain several reusable subscripts in a sequence that you need or reuse them as part of a new script.
Maciej Tomczak
Phototramp.com
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Subscripts?

Post by tomczak »

Here is an example of a reusable subscript/subroutine that can be called from the main branch, with a twist that allows the main branch to 'call' the subscript and then continue on (instead of moving to the next top-level branches) - somewhat analogous to the main program calling a subroutine in Fortran or Basic.

Some explanations:

1. The two Bypass transformations are not strictly necessary - they are there in case you would like to insert another transformation either in the main branch or a (sub)script branch without having to change the Input image in Copy transformation or Image B in Compare transformation.

2. The red arrow indicates the sequence in which transformations are executed.

3. The reusable (sub)script is the sequence of transformations that was indicated as a B&W example in the first post of this thread. It can be saved and recalled.

4. The execution starts from 1-File Open of the main branch, proceeds to 4-Bypass transformation and then leaves the main branch by virtue of 5-Copy transformation (the top one in the (sub)branch) whose input image points to the 4-Bypass). It then proceeds downstream of the (sub)script branch until it reaches its last transformation (i.e. 10-Bypass). The execution then returns to the main branch, since 10-Bypass is used as Image B in the 11-Compare transformation. The output of 11-Compare is its Image B. It continues on downstream of 11-Compare transformation in usual fashion until the last transformation (13-Export), which saves the processed image.

5. All of that can be used in a Batch mode if 1-File Open uses a list of input files.
Attachments
Subroutine Test.jpg
Subroutine Test.jpg (179.09 KiB) Viewed 2633 times
Maciej Tomczak
Phototramp.com
jsachs
Posts: 4218
Joined: January 22nd, 2009, 11:03 pm

Re: Subscripts?

Post by jsachs »

While this does work (I like the clever touch of using Compare to copy the result into the other branch), it is probably cleaner and less work to just copy the transformations into the other branch and then close the no longer needed subscript branch.

It should be possible to implement a command like this that reads in a script (first checking that it consists of just a single branch), inserts all but the top level image after the current image, and then deletes the script branch. I am working on something else right now but may come back to this later.
Jonathan Sachs
Digital Light & Color
Post Reply