title: Resizing Images using bash in Automator and retain image ratio
body: <p>I am trying to write an automator app that will take image files and resize them down to a specified width, but maintain the height/width ratio of the original image file.</p>
  
  <p>I have been trying to use sips in bash but I'm not sure where I am going wrong. I can't find anything on google to reference BASH or sips.</p>
  
  <p>I'm trying to take the height and width of the passed image, figure out the ratio and then resize the image using the target width and the target height (Calculated from the target width and ratio)</p>
  
  <p>This is my current shell script and I'm passing the image in as <code>Pass input: as arguments.</code></p>
  
  <pre><code> height=`sips --getProperty pixelHeight $@`
   width=`sips --getProperty pixelWidth $@`
   ratio=height/width
   targetWidth=262
   targetHeight=targetWidth*ratio
  
   sips --resampleHeightWidth targetHeight targetWidth $@
  </code></pre>
  
  <p>I'm not even sure if this is the right way to do it so any suggestions would be helpful.</p>