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.
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.
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)
This is my current shell script and I'm passing the image in as Pass input: as arguments.
height=`sips --getProperty pixelHeight $@`
width=`sips --getProperty pixelWidth $@`
ratio=height/width
targetWidth=262
targetHeight=targetWidth*ratio
sips --resampleHeightWidth targetHeight targetWidth $@
I'm not even sure if this is the right way to do it so any suggestions would be helpful.