Kim R
Forum Pro
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):
height = 200
'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']
'Resize image to given height and width max, while maintaining aspect ratio.'
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
}
})
'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
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):
- Default values for maximum height and width (change these to use in batch)
- A value of 0 means the width or height will not be constrained.
height = 200
- Prompt for height and width. This won't be visible if silent execution
- is set (such as in Batch). The defaults will be used instead.
'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']
- Do the resize with the specified maximum height and width
- ----- ResizeToLimit Start -----
- Author: Gary Barton
- Revision: 0.2
'Resize image to given height and width max, while maintaining aspect ratio.'
- If width or height was given as zero then make them unlimited else...
- If preserving the aspect ratio would push the height over the limit for
- the specified width then set width to None (i.e. tell PSP to figure it
- out). Otherwise, let PSP to figure out the height.
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
}
})
- ----- 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.'