New to imagemagick, need to crop image into tiles.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
griduser64
Posts: 2
Joined: 2012-06-27T10:39:58-07:00
Authentication code: 13

New to imagemagick, need to crop image into tiles.

Post by griduser64 »

I've read around and the command is,

convert -crop 32x32 terrain.png tiles/tile%03d.png

but no one ever mentions where to put the command, I've installed imagemagick and I run imagemagick display but there is no place for commands.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: New to imagemagick, need to crop image into tiles.

Post by fmw42 »

IM is primarily a command line driven system. You simply type the command in a terminal window or if using PHP, you can put the command line in an exec() call from PHP. You do not display the image first and work from the X display GUI for IM.

Syntax should be (assuming your terain.png is in the current directory from which you run the command and that tiles/ is a subdirectory of the current directory)

convert terrain.png -crop 32x32 tiles/tile%03d.png

However if you do not need to save the virtual canvas, add +repage after the crop 32x32.

see
http://www.imagemagick.org/Usage/crop/#crop
griduser64
Posts: 2
Joined: 2012-06-27T10:39:58-07:00
Authentication code: 13

Re: New to imagemagick, need to crop image into tiles.

Post by griduser64 »

It worked! Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: New to imagemagick, need to crop image into tiles.

Post by anthony »

More specifically

IM Examples, Tile Cropping
http://www.imagemagick.org/Usage/crop/#crop_tile
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply