How to automatically crop and cut an image into several images using ImageMagick?

1

How to automatically crop and cut an image into several images using ImageMagick?

Hello,

Let's say I have an image with four circles of slightly different shape like so:

O o
o O

Is there a way to make ImageMagick automatically crop, cut and save the picture into four images like so:

Pic 1: O
Pic 2: o
Pic 3: o
Pic 4: O

Vesa

Update: I would prefer if an algorithm automatically figured out which parts of the image are most likely to belong together and crop accordingly. I think Inkscape has some kind of algorithm like that.

Vesa

Posted 2018-03-29T02:34:10.883

Reputation: 310

Answers

2

If you simply need the images split into four ordered parts, you can use tile cropping like so:

convert -crop 2x2@ -scene 1 image.jpg cropped_%02d.jpg

This will split the image into four roughly equal tiles numbered from 01-04, from upper left to lower right.

Anaksunaman

Posted 2018-03-29T02:34:10.883

Reputation: 9 278

Update: I would prefer if an algorithm automatically figured out which parts of the image are most likely to belong together and crop accordingly. I think Inkscape has some kind of algorithm like that. – Vesa – 2018-03-29T12:42:43.327