1 Reply Latest reply: Dec 2, 2014 11:55 AM by xbytor2 RSS

    How to dynamically pad an image to correct the aspect ratio.

    Spektre Community Member

      I have a few thousand images I need to apply this algorithm to.  I can get most of the way ther with Actions, but the conditional logic I cannot implement.  The images are .png files with transparency and have various resolutions and aspect ratios.

       

      Load Image
      If (Image Width/Image Height) > 16/9 Then
           Set Canvas Height = Canvas Width * (9/16); center original image top to bottom; new padded pixels are transparent.
      Else
           Set Canvas Width = Canvas Height * (16/9); center original image left to right; new padded pixels are transparent.
      End If
      Save Image

       

      I need to do other things with layering as well, but that I can perform with Actions one this is completed, adn I figure babysteps with scripting.

      If you can do branching logic within the Actions framework, I'd love to know that also.

      Thanks in advance.

       

      (I am using CS6)