from JascApp import * # if you want thumbnails generated at a different size just change this to the desired value. MaxThumbnailSize = 150 def ScriptProperties(): return { 'Author': 'Joe Fromm', 'Copyright': 'Copyright (C) 2002-2003, Jasc Software Inc., All Rights Reserved. Permission to create derivate works of this script is granted provided this copyright notice is included', 'Description': 'Make a thumbnail of the current file at a size of no larger than 150x150, preserving the aspect ratio.', 'Host': 'Paint Shop Pro 8', 'Host Version': '8.00' } def Do(Environment): # compute the width and the height of image, preserving the aspect ratio ImageInfo = App.Do( Environment, 'ReturnImageInfo' ) Width = ImageInfo['Width'] Height = ImageInfo['Height'] Title = ImageInfo['Title'] if Width <= MaxThumbnailSize and Height <= MaxThumbnailSize: print 'Document %s smaller than requested thumbnail - no change made' % ( Title ) return elif Width > Height: NewWidth = MaxThumbnailSize NewHeight = Height * float(NewWidth) / float(Width) else: # height > width NewHeight = MaxThumbnailSize NewWidth = Width * float(NewHeight) / float(Height) print 'Document %s resized to %d x %d' % ( Title, NewWidth, NewHeight ) App.Do( Environment, 'Resize', { 'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 'MaintainAspectRatio': App.Constants.Boolean.true, 'OriginalDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 'OriginalResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 'Resample': App.Constants.Boolean.true, 'ResampleType': App.Constants.ResampleType.SmartSize, 'ResizeAllLayers': App.Constants.Boolean.true, 'Resolution': 100.000, 'Width': NewWidth, 'Height': NewHeight, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Match } })