Resizing image with Python with locked aspect ratio
Question: How should I resize an image with Python script so that it would automatically
adjust the Height ratio to the Width used? I'm using the following code:

    
    
    def Do(Environment):
        # Resize
        App.Do( Environment, 'Resize', {
                'AspectRatio': 1.33333, 
                'CurrentDimensionUnits': App.Constants.UnitsOfMeasure.Pixels, 
                'CurrentResolutionUnits': App.Constants.ResolutionUnits.PixelsPerIn, 
                'Height': 1440, 
                'MaintainAspectRatio': True, 
                'Resample': True, 
                'ResampleType': App.Constants.ResampleType.SmartSize, 
                'ResizeAllLayers': True, 
                'Resolution': 72, 
                'Width': 1920, 
                })
    

Using this code works perfectly if the aspect ratio of an image is the same as
the one defined in the code - i.e. 1.33333. But how should I make it work with
images that do not have this ratio? For me, what is important is that the new
Width is 1920; Height has to be able to adjust automatically. Any ideas which
part of my code should be altered and how?


Answer: According to [this forum post](http://www.webmaster-talk.com/jasc-paint-shop-
pro/28772-resize-batch-script.html),

> the magic word is None

- i.e. change
    
    
    'Height': 1440,
    

to

    
    
    'Height': None, 
    

As we found out in the comments below, you also have to set `AspectRatio` to
`None`.

