X2 resize no longer works in X6

Moderator: Kathy_9

Post Reply
altis
Posts: 1
Joined: Wed Oct 21, 2015 9:01 pm
operating_system: Windows XP Pro
System_Drive: D
32bit or 64bit: 32 Bit

X2 resize no longer works in X6

Post by altis »

I have a number of scripts created in X2 that are not going well in X6. The latest problem concerns Resize.

I need to batch resize a number of images with a variety of aspect ratios and orientations to fit on a 800x600 (landscape) digital picture frame. Here is the relevant part of the code:

Code: Select all

    Landscape = App.ActiveDocument.Width > App.ActiveDocument.Height
    if Landscape:
      # Resize
      App.Do( Environment, 'Resize', {
              'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
              'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerCM, 
              'MaintainAspectRatio': True, 
              'Resample': True, 
              'ResampleType': App.Constants.ResampleType.SmartSize, 
              'ResizeAllLayers': True, 
              'Resolution': 72, 
              'Width': 800, 
              'SharpnessValue': 50, 
              'AdvancedMode': True, 
              'GeneralSettings': {
                  'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                  'AutoActionMode': App.Constants.AutoActionMode.Match, 
                  'Version': ((12,5,0),1)
                  }
              })
    else:
      # Resize
      App.Do( Environment, 'Resize', {
              'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
              'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerCM, 
              'Height': 600, 
              'MaintainAspectRatio': True, 
              'Resample': True, 
              'ResampleType': App.Constants.ResampleType.SmartSize, 
              'ResizeAllLayers': True, 
              'Resolution': 72, 
              'SharpnessValue': 50, 
              'AdvancedMode': True, 
              'GeneralSettings': {
                  'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                  'AutoActionMode': App.Constants.AutoActionMode.Match, 
                  'Version': ((12,5,0),1)
                  }
              })
I allow for a variety of aspect ratios by missing out that parameter and either orientation by resizing for height or width as appropriate. This worked well in X2 but I'm getting all sorts of apparently random distortions in X6. How should I approach this?

As an aside, is there an up to date document that defines the parameters for each function?
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: X2 resize no longer works in X6

Post by LeviFiction »

I admit I didn't really work much on scripts back in X2 but I've never been able to resize without defining the aspect ratio. Whenever a parameter is missing or set to None it uses the last used aspect ratio. It should only recalculate if the resize dialog pops up for each image, interactively confirming the details. Or, at the very least, that's how it's always acted ever since I got into scripting.

So the answer is easy. Just set the appropriate aspect ratio.

APR = App.TargetDocument.Width / (App.TargetDocument.Height * 1.0)

And set the parameter to that variable. As I'm sure you know I multiply one of the sides by 1.0 to make the result a real number instead of an integer.

As for the most up to date APIs you can find those in in the Scripting Resources post

http://forum.corel.com/EN/viewtopic.php?f=104&t=56846

I don't believe anything was released for X7. And I don't know if the X8 Scripting API is available yet.
https://levifiction.wordpress.com/
Post Reply