Scripting Basics
A script is like a little program that runs inside a
container program (Paint Shop Pro in this case). If you find
yourself often carrying out the same sequence of commands in Paint
Shop Pro then you can speed up your work by saving the sequence of
commands into a script that you can run with a single click. Also,
once you created a script, you can apply the same script to a whole
bunch of selected images - this is called batch processing.
For example, I have made a script that resizes my high resolution
images to a smaller size - I apply this script (using batch
processing) to the many pictures that I include on my web pages.
Our scripting work will be much easier if the script toolbar
is visible. If it is not already displayed, choose View >
Toolbars > Script to view the toolbar.
Before you learn how to create you own scripts, you should know
that Paint Shop Pro contains some built-in scripts, so let's learn
how to use these first.
Running a Saved Script
You can run a saved script by selecting the script from the
Select Script drop-list in the script toolbar:
- Click the drop-list to display the scripts.
- Click the script that you want to run.
- To run the script, click Run Selected Script
(the script may take
many seconds to complete). If the 'Toggle Execution Mode' option
is turned on then
the script will present you with any dialog boxes that the
script uses, so that you can change options if you wish. If you
want don't want to make any changes (and don't want to see the
dialog boxes) then turn this option off.
Open any image that you like and try applying one of the built-in
scripts to it. I recommend you try the 'Art' script for it does a
great job simulating an oil painting. Be sure to try also the
Watercolour effect and the Infra-red effect.
Recording and Saving a Script
Most actions you perform in Paint Shop Pro are scriptable (see
the help system to learn which actions cannot be scripted).
Scripting rules of thumb: The longer a task takes to complete,
the more desirable it is to have a script for it. However, if a task
only takes two or three mouse clicks to complete, creating and
running a script for those few actions may not save you any time.
To record and save a Script:
- Make a note of or write down the specific actions you wish
to record. Ideally, your actions should be as efficient as
possible (you don't want to include mistakes or undos in your
script).
- To begin recording, click Start Script Recording
.
- Perform the actions that comprise the script.
- Click Save Script Recording
. In the Save As
dialog, do the following:
- Turn on the options 'Remove Undone Commands', 'Save
Materials' and 'Save Dialog Positions'.
- The dialog should try to save the script into the
'Restricted scripts' folder - don't change this. Scripts
saved into this folder can never harm your computer whereas
scripts placed into the 'Trusted scripts' folder could
possibly harm your computer (in more advanced work you might
in some cases need to include those risky commands that can
cause damage if misused).
- Enter a name for the script, and then click Save.
Editing Scripts
The script toolbar includes a button 'Edit Selected Script' which
allows you modify the text of the script (which is written in the
Python scripting language). This is beyond the scope of this course,
so if you want to modify a script you will have to delete it and
make a new version.
Batch Processing (Processing Multiple Files)
You can apply the same script to multiple files automatically by
using batch processing (you can also use batch processing to rename
multiple files, but that won't be explained here). To apply a script
to multiple files:
- Open the Batch Process dialog by choosing File > Batch >
Process.
- Click the Browse button (located in the Batch Process
dialog's upper right corner) to open the Select Files dialog.
Use the Select Files dialog to navigate to the folder containing
the source (original) files.
- Click the files you want to process. Note that you can
Shift-click to select adjacent files, or Ctrl-click to select
non-adjacent files.
- When you've chosen the files to process, click Select.
In the Batch Process dialog, the files you chose will appear in
the Files to process list.
- Use the Script section of the dialog to run a script on all
the files. Make sure the Use Script check box is selected. You
can then choose the desired script from the list. Mark the
Run script in silent mode check box to ensure the script
does not present you with dialog boxes while it runs.
- In the Save Mode section of the dialog, choose one of the
following options:
- New Type: This option is not relevant to us, so
don't choose it. You would choose this option if you simply
want to convert a bunch of files from from one format to
another e.g. from pspimage format to jpeg (as well as
possibly running a script). The modified file would be saved
in the same folder as the original.
- Copy: This is the best
option for us since we probably do not want to
overwrite the original file - we want to save a modified
copy of the original file. This option requires that a
script is defined in the Script group box. This option will:
a) read in the file, b) apply the script to the file, and c)
save the file to a new location and/or name.
- Overwrite: This option requires that a script is
defined in the Script group box. This option will: a) read
in the file, b) run the script against the file, and c) save
the file to its original location (the original file is
overwritten).
- Obey Script: you would only use this option when
you know the script performs a save, which is not our case
so do not choose this option (otherwise nothing will
happen).
- In the Save Options section of the dialog, you can set the
following (as mentioned above, your Save Mode setting affects
what is available here):
- Unless you specify another output folder, Paint Shop Pro
saves the converted files in the same folder as the source
files. Optionally, you can designate another output
(destination) folder for the new files by typing a path in
the Folder field, or by clicking the Browse button next to
this field and navigating to another folder.
- You also have the option of renaming the
converted files. To do so, click Modify to open the Modify
Filename Format dialog. The Rename Options list displays the
choices for renaming your files. Select an option and click
Add to move it into the Included list. Choose from the
following options:
- Custom Text When you choose this option, the
program displays a Custom text field below the Included
list. In this field type the text you want applied to
the converted files.
- Date The current date is added to the name.
- Document Name Include the original name in
the new name, but also allows for case changes (upper,
lower, etc.).
- Sequence The position of a file in the
renaming process is added to each file.
- Time The current time is added to the name.
- Use the Move Up and Move Down buttons if you wish to
rearrange the Rename options you've included.
- A preview of the new file naming scheme appears at the
bottom of the dialog. Click OK to close the Modify Filename
Format dialog and return to the Batch Process dialog.
- Click Start.