the script is lock in to the way it was recorded. There's no options for making adjustments as it runs.
With Scripting you can create those options and adjustment automatically.
I'm sharing my Basic Starter script for anyone who learning how to edit their scripts for the first time, so they
can get the most out of their work. There just some things that a scripts needs, to make them better.
Here I have done all the basic work for you, collecting the most useful information you'll need to get started
editing your scripts. I use this script to help me get the most out of my ideas.
What does this script do for you....
1. Clear script window out put.
2. Check to see if you have an open image to work with.
3. Display a copy right window.
4. Make sure the open image is on a single layer.
5. Gets image size in Pixels
6. Gets image size in Inches
7. Calculates the center locations for each size of image
8. Has a Paint-shop Pro Version checker
All the basic numbers you'll need to get started.
At the end of the script are Paint Shop Pro Environmental Run commands that return
all information about an open image (EXIF) and the syntax command (the keys) that calls them out. To use them,
just remove the "#" comment syntax from each line and run script. Make sure you have the script
output window open to see what's available to use.
You may use this script freely with any of your script. Do not sell it, but share it as is.
Your welcome to change any of the information to meet your needs including the Copyright on line 63.
And happy scripting
Code: Select all
# Date Created 2017
# Last updated: 02/13/2018
# Version 1.1
# Basic Starter Script for editors.
# Created by Timothy Gene Vesper.
#
# Variable list and usages in this script'
#
# TargetedVersion = Paint Shop Pro Version needed for script to run correctly.
# ImageMainInfo = All of Paint Shop pro possible information of the open image. (EXIF)
# DotsPerInch = Pixels per inch of Image
# DocWidthSize = Width of image in Pixels
# DocHeightSize = Height of image in Pixels
# PaintShopVersion = Version number of Paint Shop Pro running script.
# CenterPoint1 = centre point location of Width of image in Pixels
# CenterPoint2 = centre point location of Height of image in Pixels
# BaseMaxSize = the longest side of the open image in Pixels
# BaseMinSize = The shortest side of the open image in Pixels
# SetInchesW = The Width of the open Image in inches to the tenth of and inch for calculation.
# SetInchesH = The Height of the open Image in inches to the tenth of and inch for calculation.
# X = Just a Temp Variable
#
# At the end of the script are PaintShop Pro Environmental Run commands that return
# all information about an open image (EXIF) and the syntax command (the keys) that calls them out. To use them,
# just remove the "#" comment syntax from each line and run script. Make sure you have the script
# output window open to see what's available to use.
#
# You may use this script freely with any of your script. Do not sell it, but share it as is.
# Your welcome to change any of the information to meet your needs including the Copyright on line 63.
from PSPApp import *
import random
def ScriptProperties():
return {
'Author': u'Your Name Goes here',
'Copyright': u'Your Name Goes Here and Date',
'Description': u'Script Name Goes Here',
'Host': u'Paint Shop Pro Photo',
'Host Version': u'20.00'
}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((12,0,1),1)
}
})
# Clear script window and start script
App.Do( Environment, 'ScriptWndClear')
# Copy Right Message
ButtonTypes = ('OK/Yes' )
result = App.Do(Environment, 'MsgBox', {
'Buttons': App.Constants.MsgButtons.OKCancel,
'Icon': App.Constants.MsgIcons.Info,
'Text': 'Basic Starter Script #01 \n Version 1.00a for PSP 2018\n\nScript © By Timothy Gene Vesper',
})
if result == 0:
return
# Check for a open image to work with
if App.TargetDocument is None:
result = App.Do(Environment, 'MsgBox', {
'Buttons': App.Constants.MsgButtons.OK,
'Icon': App.Constants.MsgIcons.Stop,
'Text': 'You need to have a open image to work with! '
})
if App.TargetDocument is None:
return
# do we have a single layer to work with
DocInfo = App.Do( Environment, 'ReturnImageInfo' )
if DocInfo[ 'LayerNum' ] != 1:
App.Do(Environment, 'MsgBox', {
'Buttons': App.Constants.MsgButtons.OK,
'Icon': App.Constants.MsgIcons.Stop,
'Text': 'This script requires that your image consist of only a single layer! '
})
if DocInfo[ 'LayerNum' ] != 1:
return
# Get all basic image data for calculations
TargetedVersion = 20
ImageMainInfo = App.Do( Environment,'ReturnImageInfo')
ProgramVersion = App.Do(Environment, 'GetVersionInfo')
DotsPerInch = int (ImageMainInfo['PixelsPerUnit'])
DocWidthSize = int (ImageMainInfo['Width'])
DocHeightSize = int (ImageMainInfo['Height'])
PaintShopVersion = int (ProgramVersion['MajorVersion'])
# Clear script window and start script
App.Do( Environment, 'ScriptWndClear')
# Get the longest side to base border width with
CenterPoint1 = int (DocWidthSize) / 2
CenterPoint2 = int (DocHeightSize) / 2
BaseMaxSize = max(DocWidthSize, DocHeightSize)
BaseMinSize = min(DocWidthSize, DocHeightSize)
SetInchesW = round((float(DocWidthSize) / float(DotsPerInch)),2)
SetInchesH = round((float(DocHeightSize) / float(DotsPerInch)),2)
# show information selected to use
print '\n Gathering information... \n'
print 'Paint Shop Version', PaintShopVersion
print '\nImage is: ', SetInchesW, 'inches in width'
print 'Image is: ', SetInchesH, 'inches in height'
print '\nWidth total is ', DocWidthSize, 'Pixels'
print 'Height total is ', DocHeightSize, 'Pixels'
print 'pixels per inch are set to ', DotsPerInch
print '\nCenter point width is located at ', CenterPoint1
print 'Center point Height is located at ', CenterPoint2
print '\nLongest side of image is:', BaseMaxSize, 'pixels'
print 'Shortest side of image is:', BaseMinSize, 'Pixels'
print '\nRandomize options are imported to use'
print 'A list of 8 random numbers from 10-100\n'
# Show random numbers
x = 1
while x < 9:
print(random.randrange(10,101)), ', ',
x += 1
print ' '
RandomNumber1 = (random.randrange(10,101))
print '\nRandom Number Selected: ', RandomNumber1
print '\nChecking Version '
if PaintShopVersion < TargetedVersion:
print '\nThis script is for PaintShop Pro 2018'
return
else:
print 'Version is meet and Script continues\n'
#ImageInfo = App.Do( Environment, 'ReturnImageInfo',)
#for key in ImageInfo:
# print '%-30s: %s' % (key, ImageInfo[key])
#Version = App.Do(Environment, 'GetVersionInfo')
#for key in Version:
# print '%s - %s' % (key, Version[key]) 