Kris Huber
Kris Huber

Reputation: 108

How to set offset when cropping images in imagemagick

My situation is the following: I have about 7k images (they are all the same resolution) that I need to crop with an offset of 2px x 2px y how can I archive this? I already figured out how to run the command for every image in the directory.

I have also tried running

convert image.jpg -crop 97x97 cropped.jpg

It has no offset and it spits out several images instead of just the first cropped one.

Upvotes: 1

Views: 564

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207365

You should find this works:

convert INPUT.JPG -crop 97x97+2+2 RESULT.JPG

If so, make a copy of a few files in a spare directory and try with:

cd spare
mogrify -crop 97x97+2+2 *.jpg

Or, if you want them done faster, use GNU Parallel:

cd spare
parallel mogrify -crop 97x97+2+2 {} ::: *.jpg

Upvotes: 2

Related Questions