-1

I am trying to create a script that splits any input image into 4 different parts (2x2).

I tried the following:

convert "$1" -crop 50%x50% +repage output%d.jpg

With some input images it generates the following files as expected and they are correctly split:

output0.jpg
output1.jpg
output2.jpg
output3.jpg

However with some other input images it only creates 3 output files. It actually never creates the the 4th quarter.

Could this be a bug or should I use another way for achieving this?

1
  • Please post an example input image that fails your command
    – fmw42
    Commented Jul 4 at 15:23

1 Answer 1

3

I'm not sure why the command gives those results, but a "-gravity" setting could affect a crop operation like that. Also the input image page geometry could make the operation act in ways that might not be expected

If I want to crop an image into quarters I would use a command like this...

magick input.png -crop 2x2@ result%02d.png

The "@" flag tells the operation to crop into 2 columns and 2 rows as equally as possible.

If you provide a sample of one of the images that causes the problem we can see if there might be better answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.