Users Browsing Forum
No Members and 1 Guests
resizing "if" This thread currently has 221 views.
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
I'm looking for a script to resize a batch of jpg files "if" the width is 701 pixels or larger. If the width is 700 pixels or less, the image needs to retain it's original size. Anything 701 pixels wide or larger needs to be resized (lock aspect ratio) to 700 pixels wide. Thanks, Paige
2007 Curriculum Guides #01 - #28 Now Posted
Willy
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
Logged
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
Thanks for the quick reply. I don't see where these can accomplish what I need. I want it to not touch the images that are smaller than the desired size. Am I missing something (very possibly!)? Thanks, Paige
Willy
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
See if this script will work. I didn't test it very much. from PSPApp import * def ScriptProperties(): return { 'Author': u'', 'Copyright': u'', 'Description': u'', 'Host': u'Paint Shop Pro Photo', 'Host Version': u'11.20' } def Do(Environment): # EnableOptimizedScriptUndo App.Do( Environment, 'EnableOptimizedScriptUndo', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((11,2,0),1) } }) # ReturnImageInfo ImageInfo = App.Do( Environment, 'ReturnImageInfo',) if ImageInfo['Width'] > 700: # Resize App.Do( Environment, 'Resize', { 'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 'Height': None, 'MaintainAspectRatio': True, 'Resample': True, 'ResampleType': App.Constants.ResampleType.SmartSize, 'ResizeAllLayers': True, 'Resolution': None, 'Width': 700, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((11,2,0),1) } }) else: print "**** Image Width is 700 or Less. ****"
Logged
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
This works really well except that it's changing the height improperly. The height of tested files actually got larger. For example, I had an image that was originally 728 x 418 but once I applied the script, it was 700 (yay!) x 906. Any ideas?
Very happy with the width and note that it did not touch those files that were originally smaller than 700 pixels wide.
Willy
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
Hmmm.... I tried an image of 728 X 418 and it resized to 700 X 402. I don't know where the 906 got into the resize.
Logged
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
My apologies I introduced an error. Seems to work exactly as I wanted. Many, many thanks!
Willy
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
Glad it works.
Here is a little different one that has to go in the trusted folder since it calls the os module. It prints the file name if it is less than 700. Good if you are doing a batch process.
from PSPApp import *
import os
def ScriptProperties():
return {
'Author': u'',
'Copyright': u'',
'Description': u'',
'Host': u'Paint Shop Pro Photo',
'Host Version': u'11.20'
}
def Do(Environment):
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((11,2,0),1)
}
})
# ReturnImageInfo
ImageInfo = App.Do( Environment, 'ReturnImageInfo',)
ImageName = ImageInfo['FileName']
FilePath, FileName = os.path.split(ImageName)
if ImageInfo['Width'] > 700:
# Resize
App.Do( Environment, 'Resize', {
'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels,
'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn,
'Height': None,
'MaintainAspectRatio': True,
'Resample': True,
'ResampleType': App.Constants.ResampleType.SmartSize,
'ResizeAllLayers': True,
'Resolution': None,
'Width': 700,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((11,2,0),1)
}
})
else:
print "****",FileName," -- Image Width is 700 or Less. ****"
Download here:
http://willy.250free.com/downloads/zw-test-resize-width-700-plus.Pspscript
Revision History (1 edits)
Willy - October 6, 2009, 7:28pm
Logged
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
That's good stuff. Thanks for the help Willy. Glad I found the forum. Paige
Willy
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
Forgot to mention if you use the last one I posted you need to take the first out of the restricted script folder. Scripts are fun. Wish I had more time to mess with them.
Logged
rnguslo
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
They are fun. I wish I knew more about them!
READ ME FIRST-This is "REQUIRED READING" before posting Announcements Board Issues Chat Room General Discussion PSP v.7 Evaluations and Problems PSP v.8 Evaluations and Problems PSP v.9 Evaluations and Problems PSP v.X Evaluations and Problems PSP v.X1 Evaluations and Problems PSP v.X2 Evaluations and Problems Photo Help & Discussion HTML Discussion Animation Shop Scrappers ShutterBox Self Learning Programme Discussion The Showcase Archives and FAQ's Tutorials and Tips Scripts Downloads Recommended Books Test
Thread Rating
There is currently no rating for this thread