简体   繁体   中英

Using imagemagick how can i slice up an image into several separate images?

Please consider following example:

在此输入图像描述

The source image consists of 6 areas that need to be sliced up into 6 separate images.

How can I get the desired output using imagemagick. I tried to understand a possible solution presented in the imagemagick examples , but failed to transfer it to my specific problem.

What would be a way of solving this problem preferably in a one-liner? Since all the areas which i want to slice have the same size, but only differ in their offset, is there a way to somehow pass a preset area size, and then simply add the xy-offset for each area?

If each area has the same amount of padding around it, you can use the @ operator .

This cuts an image into 6 sections, 2 per row, with 40 pixels of horizontal padding and 20 pixels of vertical padding excluded from each section:

convert image.png -crop 2x3-40-20@ +repage +adjoin tile-%d.jpg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM