Slice and Dice Images with ImageMagick
on December 10, 2008
You can use the convert command that comes with ImageMagick to extract parts of an image.
You can cut out a 100-pixel-wide chunk from somewhere in the middle of an image:
$ convert -crop 100x+0+0 orig/wrapperbg775.gif slice0.gif $ convert -crop +200+0 orig/wrapperbg775.gif slice1.gif $ convert +append slice0.gif slice1.gif wrapperbg675.gif
You can duplicate a 100-pixel-wide chunk from somewhere in the middle of an image:
$ convert -crop 100x+100+0 orig/wrapperbg775.gif slice100.gif $ convert +append slice0.gif slice100.gif slice 100.gif ↪slice1.gif wrapperbg875.gif
Note that there was no need to specify the height of the image in any of the above commands. If you need to adjust the height instead of the width, the steps are similar, but use -append instead of +append to paste the slices vertically.