By Prof November 21, 2009, 10:17am
Learn more about Corel Paint Shop Pro Photo X2
Save up to 30%
Paint Shop Pro Photo X2 Ultimate
New $69.99 - Upgrade $49.99
Free e-book
Free Shipping



(Please note that in registering use only 8 characters or less for Password)
Welcome, Guest. Please login or register.

Forum Login
Login Name: Create a new account
Password:     Forgot password

PSPUG Message Board    Library    Scripts  ›  resizing "if" Moderators: Willy, Pete
Users Browsing Forum
No Members and 1 Guests

resizing "if"  This thread currently has 222 views. Print
1 Pages 1 Recommend Thread
rnguslo
October 5, 2009, 3:23pm Report to Moderator
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
Logged Offline
E-mail Private Message

2007 Curriculum Guides #01 - #28 Now Posted
Willy
October 5, 2009, 4:41pm Report to Moderator

Board Moderator
Posts: 1333
Posts Per Day: 0.68
Reputation: 100.00%
Time Online: 33 days 5 hours 54 minutes
See if Gary Barton's ResizeToLimit will work. You can get it here along with some other scripts.

http://pixelnook.vapho.com/index_All.html


Logged
Private Message Reply: 1 - 10
rnguslo
October 5, 2009, 6:43pm Report to Moderator
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
Logged Offline
E-mail Private Message Reply: 2 - 10
Willy
October 5, 2009, 7:26pm Report to Moderator

Board Moderator
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
Private Message Reply: 3 - 10
rnguslo
October 6, 2009, 5:23pm Report to Moderator
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.  
Logged Offline
E-mail Private Message Reply: 4 - 10
Willy
October 6, 2009, 6:07pm Report to Moderator

Board Moderator
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
Private Message Reply: 5 - 10
rnguslo
October 6, 2009, 6:20pm Report to Moderator
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!  
Logged Offline
E-mail Private Message Reply: 6 - 10
Willy
October 6, 2009, 6:24pm Report to Moderator

Board Moderator
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
Private Message Reply: 7 - 10
rnguslo
October 6, 2009, 6:29pm Report to Moderator
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
Logged Offline
E-mail Private Message Reply: 8 - 10
Willy
October 6, 2009, 6:35pm Report to Moderator

Board Moderator
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
Private Message Reply: 9 - 10
rnguslo
October 6, 2009, 6:46pm Report to Moderator
Member
Posts: 6
Posts Per Day: 0.13
Time Online: 46 minutes
They are fun. I wish I knew more about them!
Logged Offline
E-mail Private Message Reply: 10 - 10
1 Pages 1 Recommend Thread
Print

PSPUG Message Board    Library    Scripts  ›  resizing "if"

Thread Rating
There is currently no rating for this thread
 


Powered by E-Blah Forum Software 10.3 © 2001-2007

Valid XHTML Valid CSS Sourceforge.net Powered by Perl