Use sips command on mac to trim bottom of image

It's only taken me 2 years to think this up... but you can do it with the GD library which is actually included in the standard, built-in OSX PHP interpreter (so no need to install any packages):

#!/usr/bin/php -f

<?php
   $im = imagecreatefromjpeg("image.jpg");
   $crop_area = array('x'=>0,'y'=> 0,'width'=>640,'height'=>960);
   $result = imagecrop($im, $crop_area);
   imagejpeg($result,"result.jpg");
?>

To call from Terminal, you would save it in a file, called say chopper and then make the file executable like this:

chmod +x chopper

and then you could run it by typing:

./chopper

or double-clicking it in Finder.

I guess you would want to make it take parameters of the filename to open and the filename to save and the dimensions, but you get the idea.


Doesn't look like it's possible. Thanks guys.


You could also use the flip mode twice.

sips --flip vertical image.jpg
sips --cropToHeightWidth 640 960
sips --flip vertical image.jpg

This has done it for me.


Update

Like the comments says this solution does not work any longer. Sorry for that.