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?
To crop an image using ImageMagick, you need to specify the X and Y coordinates of the top corner of the crop rectangle and the width and height of the crop rectangle. Use the mogrify command if you want the images to be replaced in-place or use the convert command otherwise to make a copy.
Use ImageMagick® to create, edit, compose, or convert digital images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, WebP, HEIC, SVG, PDF, DPX, EXR and TIFF.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With