Paintshop pro X3 batch resize

Corel Paint Shop Pro

Moderator: Kathy_9

Post Reply
purepanda
Posts: 1
Joined: Tue Jan 19, 2016 10:09 am
operating_system: Windows 8
System_Drive: C
32bit or 64bit: 64 Bit

Paintshop pro X3 batch resize

Post by purepanda »

Ok I got 1000's of images to resize I know how to batch resize what I need to know is how to batch it to resize the longest dimension to 500Pixels whilst keeping the aspect ratio
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8-2023
Location: USA

Re: Paintshop pro X3 batch resize

Post by LeviFiction »

With anything older than X8 you need to use a script to resize by the long side. This is because in older versions you have to manually calculate each side and the aspect ratio.

PSPX8 added a 'resize by side" option into its Resize dialog.

Here is a simple script that does what you want. The code is a bit messy as it comes from an experiment I was doing but it should work.

To change the length (in pixels) of the side just change the variable "LongSideSize" to whatever value you want. You can see in this code it's set to 500.

Just copy this code into notepad. Save it in your Scripts-Restricted folder with the extension "PSPScript" and it should work. Just execute this script in the batch process window.

Code: Select all

from JascApp import *

def ScriptProperties():
    return {
        # Change this to be your own information
        'Author': u'',
        'Copyright': u'',
        'Description': u'',
        'Host': u'Paint Shop Pro',
        'Host Version': u'8.00'
        }

def Do(Environment):
    NewWidth = App.TargetDocument.Width
    NewHeight = App.TargetDocument.Height

    LongSideSize = 500

    result = App.Do(Environment, 'ReturnImageInfo')

    #Determine which side should be 500px
    if App.TargetDocument.Width > App.TargetDocument.Height:
        NewWidth = LongSideSize
    else:
        NewHeight = LongSideSize

    ImageResize(Environment, App.TargetDocument, Width = NewWidth, Height=NewHeight, Units = result['Unit'], Resolution = result['PixelsPerUnit'])


    
def ImageResize(Environment, Doc, Width=-1, Height= -1, AspectRatio =-1, MaintainAspectRatio = True, Resample = True, ResizeAllLayers = True, Resolution = 72, Units = "Pixels", Sharpness = 50):
    if Units == "Inches":
        Units = App.Constants.ResolutionUnits.PixelsPerIn
    else:
        Units = App.Constants.ResolutionUnits.PixelsPerCM
        
    if AspectRatio == -1:
        AspectRatio = Doc.Width / (Doc.Height *1.0)
        
    if Width == -1 and Height == 1:
        return
    else:
        if Width == -1:
            Width = Height * AspectRatio
        elif Height == -1:
            Height = Width / ApsectRatio
    
    App.Do( Environment, 'Resize', {
            'AspectRatio': AspectRatio, 
            'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
            'CurrentResolutionUnits': Units, 
            'Height': Height, 
            'MaintainAspectRatio': MaintainAspectRatio, 
            'Resample': Resample, 
            'ResampleType': App.Constants.ResampleType.Bicubic, 
            'ResizeAllLayers': ResizeAllLayers, 
            'Resolution': Resolution, 
            'Width': Width, 
            'SharpnessValue': Sharpness, 
            'AdvancedMode': False, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((8,0,0),1)
                }
            }, Doc)

https://levifiction.wordpress.com/
Post Reply