I have a really large map image (11010*17518 pixels) and I want to print it in average size pieces. Is there any automatic script that can crop a image by checkered (e.g. into 4*4 and get 16 smaller images)?


You could do it with MagickSlicer (https://github.com/VoidVolker/MagickSlicer). According to the documentation there are parameters

[ -w, --width <tile_width> ]
Set tile width.

Default: 256 pixels or same as height, if height is present.

Type: int

[ -h, --height <tile_height> ]
Set tile height

Default: 256 pixels or same as width, if width is present.

Type: int

The command would be

./magick-slicer.sh -w 2753 -h 4380 <your image>

I am not sure where magick-slicer outputs the sliced images, but it should be no problem finding them. You can see the directory structure to help you find sliced images. There are also other options documented like output dir.

Another solution would be to use crop option of ImageMagick https://imagemagick.org/Usage/crop/#crop. That would require 16 crops of the original, that could be done in two for loops. Something like that:

for x in 1 2 3 4 do
    for y in 1 2 3 4 do
        convert <input_image> -crop WxH+X+Y +repage <output_image>

You would have to do some math to make W, H, X, Y, and output image name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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