home *** CD-ROM | disk | FTP | other *** search
/ PC Extra 07 & 08 / pca1507.iso / Software / psp8 / Data1.cab / Thumbnail_150.PspScript < prev    next >
Encoding:
Text File  |  2003-04-22  |  2.3 KB  |  52 lines

  1. from JascApp import *
  2.  
  3. # if you want thumbnails generated at a different size just change this to the desired value.
  4. MaxThumbnailSize = 150
  5.  
  6. def ScriptProperties():
  7.     return {
  8.         'Author': 'Joe Fromm',
  9.         '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',
  10.         'Description': 'Make a thumbnail of the current file at a size of no larger than 150x150, preserving the aspect ratio.',
  11.         'Host': 'Paint Shop Pro 8',
  12.         'Host Version': '8.00'
  13.         }
  14.  
  15. def Do(Environment):
  16.     # compute the width and the height of image, preserving the aspect ratio
  17.     ImageInfo = App.Do( Environment, 'ReturnImageInfo' )
  18.     Width = ImageInfo['Width']
  19.     Height = ImageInfo['Height']
  20.     Title = ImageInfo['Title']
  21.     
  22.     if Width <= MaxThumbnailSize and Height <= MaxThumbnailSize:
  23.         print 'Document %s smaller than requested thumbnail - no change made' % ( Title )
  24.         return
  25.     elif Width > Height:
  26.         NewWidth  = MaxThumbnailSize
  27.         NewHeight = Height * float(NewWidth) / float(Width)
  28.     else:   # height > width
  29.         NewHeight = MaxThumbnailSize
  30.         NewWidth  = Width * float(NewHeight) / float(Height)
  31.  
  32.     print 'Document %s resized to %d x %d' % ( Title, NewWidth, NewHeight )
  33.     
  34.     App.Do( Environment, 'Resize', {
  35.             'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
  36.             'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 
  37.             'MaintainAspectRatio': App.Constants.Boolean.true, 
  38.             'OriginalDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
  39.             'OriginalResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 
  40.             'Resample': App.Constants.Boolean.true, 
  41.             'ResampleType': App.Constants.ResampleType.SmartSize, 
  42.             'ResizeAllLayers': App.Constants.Boolean.true, 
  43.             'Resolution': 100.000, 
  44.             'Width': NewWidth, 
  45.             'Height': NewHeight, 
  46.             'GeneralSettings': {
  47.                 'ExecutionMode': App.Constants.ExecutionMode.Silent, 
  48.                 'AutoActionMode': App.Constants.AutoActionMode.Match
  49.                 }
  50.             })
  51.  
  52.