Using Script??

Kim R

Forum Pro
Messages
17,895
Reaction score
82
Location
Burns, OR, US
I have down loaded and used actions and have no problem with that. How do I use a script when after getting it using PS CS ?

I have been trying to figure out how to use this script (downloaded today)to batch resize - I have it saved in C:\Program Files\Adobe\Photoshop CS\ScriptsRestricted# Sample script using ResizeToLimit

Your help here would be appreciated and thank you in advance.

from JascApp import *

def ScriptProperties():
return {
'Author': u'Gary Barton',
'Copyright': 'Copyright © 2003 Gary Barton.',

'Description': u'Resize image to given height and width max, while maintaining aspect ratio.',
'Host': u'Paint Shop Pro',
'Host Version': u'8.01'
}

def Do(Environment):
  1. Default values for maximum height and width (change these to use in batch)
  2. A value of 0 means the width or height will not be constrained.
width = 200
height = 200
  1. Prompt for height and width. This won't be visible if silent execution
  2. is set (such as in Batch). The defaults will be used instead.
result = App.Do( Environment, 'GetNumber', {
'DefaultValue': width,
'MinValue': 0,
'MaxValue': 65535,
'DialogTitle': 'GetNumber - ResizeToLimit',
'Prompt': 'Maximum width (enter 0 for none)',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default
}
})
if not result['OKButton']:
return
width = result['EnteredNumber']
result = App.Do( Environment, 'GetNumber', {
'DefaultValue': height,
'MinValue': 0,
'MaxValue': 65535,
'DialogTitle': 'GetNumber - ResizeToLimit',
'Prompt': 'Maximum height (enter 0 for none)',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default
}
})
if not result['OKButton']:
return
height = result['EnteredNumber']
  1. Do the resize with the specified maximum height and width
ResizeToLimit(Environment, Height=height, Width=width)
  1. ----- ResizeToLimit Start -----
  2. Author: Gary Barton
  3. Revision: 0.2
def ResizeToLimit(Environment, Height, Width):
'Resize image to given height and width max, while maintaining aspect ratio.'
  1. If width or height was given as zero then make them unlimited else...
  2. If preserving the aspect ratio would push the height over the limit for
  3. the specified width then set width to None (i.e. tell PSP to figure it
  4. out). Otherwise, let PSP to figure out the height.
if Width == 0 and Height == 0:
return
if Width == 0:
Width = None
elif Height == 0:
Height = None

elif ((float(Width) / App.TargetDocument.Width) * App.TargetDocument.Height) > Height:
Width = None
else:
Height = None

App.Do( Environment, 'Resize', {
'AspectRatio': None, # Let PSP figure it out
'Height': Height,
'Width': Width,
'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels,
'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn,
'MaintainAspectRatio': App.Constants.Boolean.true,
'Resample': App.Constants.Boolean.true,
'ResampleType': App.Constants.ResampleType.SmartSize,
'ResizeAllLayers': App.Constants.Boolean.true,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})
  1. ----- ResizeToLimit End -----
--

'The very fact that I find myself in agreement with you other minds perturbs me, so that I hunt for points of divergence, feeling the urgent need to make it clear that at least I reached the same conclusions by a different route.'
KimR
 
Kim:

In PS7 (which I have), the folder for scripts is:

C:\Program Files\Adobe\Photoshop 7.0\Presets\Scripts

========

In CS is the equivalent

C:\Program Files\Adobe\Photoshop CS\Scripts ??

or is it

C:\Program Files\Adobe\Photoshop CS\Presets\Scripts ??

Reason I ask: File location is very important. Wrong folder and you're toast before you start.

========

Is the name of the script:

Restricted# Sample script using ResizeToLimit.js ?

========

To play the script:
  • Open an image to which you want to apply the script
  • From the File menu, the choice is either
File > Automate > Scripts

-or- it may be something like

File > Scripting
  • From the scripts dialog click on the name of the script and click OK. That should launch it.
========

Something interesting... Looks like this script was crafted using (or for) PaintShop Pro:
'Host': u'Paint Shop Pro',
'Host Version': u'8.01'
'AspectRatio': None, # Let PSP figure it out
It will be interesting to see if it will run with Photoshop. Cool if yes.

Danny
I have down loaded and used actions and have no problem with that.
How do I use a script when after getting it using PS CS ?

I have been trying to figure out how to use this script (downloaded
today)to batch resize - I have it saved in C:\Program
Files\Adobe\Photoshop CS\ScriptsRestricted# Sample script using
ResizeToLimit

Your help here would be appreciated and thank you in advance.

from JascApp import *

def ScriptProperties():
return {
'Author': u'Gary Barton',
'Copyright': 'Copyright © 2003 Gary Barton.',
'Description': u'Resize image to given height and width max, while
maintaining aspect ratio.',
'Host': u'Paint Shop Pro',
'Host Version': u'8.01'
}

def Do(Environment):
  1. Default values for maximum height and width (change these to use
in batch)
  1. A value of 0 means the width or height will not be constrained.
width = 200
height = 200
  1. Prompt for height and width. This won't be visible if silent
execution
  1. is set (such as in Batch). The defaults will be used instead.
result = App.Do( Environment, 'GetNumber', {
'DefaultValue': width,
'MinValue': 0,
'MaxValue': 65535,
'DialogTitle': 'GetNumber - ResizeToLimit',
'Prompt': 'Maximum width (enter 0 for none)',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default
}
})
if not result['OKButton']:
return
width = result['EnteredNumber']
result = App.Do( Environment, 'GetNumber', {
'DefaultValue': height,
'MinValue': 0,
'MaxValue': 65535,
'DialogTitle': 'GetNumber - ResizeToLimit',
'Prompt': 'Maximum height (enter 0 for none)',
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default
}
})
if not result['OKButton']:
return
height = result['EnteredNumber']
  1. Do the resize with the specified maximum height and width
ResizeToLimit(Environment, Height=height, Width=width)
  1. ----- ResizeToLimit Start -----
  2. Author: Gary Barton
  3. Revision: 0.2
def ResizeToLimit(Environment, Height, Width):
'Resize image to given height and width max, while maintaining
aspect ratio.'
  1. If width or height was given as zero then make them unlimited
else...
  1. If preserving the aspect ratio would push the height over the
limit for
  1. the specified width then set width to None (i.e. tell PSP to
figure it
  1. out). Otherwise, let PSP to figure out the height.
if Width == 0 and Height == 0:
return
if Width == 0:
Width = None
elif Height == 0:
Height = None
elif ((float(Width) / App.TargetDocument.Width) *
App.TargetDocument.Height) > Height:
Width = None
else:
Height = None

App.Do( Environment, 'Resize', {
'AspectRatio': None, # Let PSP figure it out
'Height': Height,
'Width': Width,
'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels,
'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn,
'MaintainAspectRatio': App.Constants.Boolean.true,
'Resample': App.Constants.Boolean.true,
'ResampleType': App.Constants.ResampleType.SmartSize,
'ResizeAllLayers': App.Constants.Boolean.true,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})
  1. ----- ResizeToLimit End -----
 
It's my understanding that PaintShop Pro "scripts" and PS "actions" are not interchangeable and can only be run in their respective programs. The only way is to write an action based on the steps you see in a script. It would defintely be cool if someone were to come up with a program to convert one into the other! (Me, I want actions into scripts since I use PSP.)

Plugins normally work in both.

Elizabeth
efg40
FZ1-2er
 

Keyboard shortcuts

Back
Top