I'm trying to crop large batches of images automatically. I'm currently using Automator's Crop Images action, but it is lacking in options. I can specify a width and height, and then it performs a centered crop. I want to be able to specify X and Y as well as width and height (to use Xcode terms), so I can perform a consistent crop for any custom rectangle. Are there better, more featureful cropping actions available? Preferably for free... :)
Here is a way to achieve what you want with ImageMagick. Hopefully you’re comfortable using Terminal (and also use Homebrew to manage all your packages).
Either way, you must install ImageMagick so you can run
convert command line in Terminal.
Open the folder you want to batch processing all the images. If your folder name called images is located on Desktop, you’ll need to enter
cd ~/Desktop/images/in Terminal.
ImageMagick have a built-in option to crop images according to sizes and coordinates. The command is:
convert <input documents> <width>x<height>+<pos x>+<pos y> <output filepath>
Cropping Images with ImageMagick
If I want to crop all the images into:
- Width: 300px
- Height: 500px
- Position X: 100px from top left
- Position Y: 70px from top left
I can enter the command below:
convert *.jpg -crop 300x500+100+70 result/screenshot.jpg
Make sure the target filepath exists. In this case, you should create a folder called
result in Desktop. Or you can use absolute path like
~/Desktop/result or whatever folder you want to point. Just drag the folder into Terminal like this: