Use sips command on mac to trim bottom of image

爷,独闯天下 提交于 2019-11-30 11:32:32

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!