Steve A
Steve A

Reputation: 2001

Cropping with ImageMagick always results in 1x1 images

I'm trying to crop an image into a bunch of 256x256 tiles (with the right-most and bottom-most images less than 256 pixels due to the remainders), but ImageMagick always generates images that are 1x1.

I use this command (Windows 7 command prompt):

convert WBS.png -crop 256x256 +repage +adjoin output\WBS_%02d.jpg

After cropping the following message is displayed:

convert: geometry does not contain image `WBS.png' @ warning/transform.c/CropImage/589.

After cropping, the output folder contains 1634 jpg files, all of which are 1 x 1 pixel. The source image is 7218x7650.

Suggestions? I'm sure I'm making some blatant mistake, but I don't know what it is.

Upvotes: 5

Views: 1620

Answers (1)

Meyer
Meyer

Reputation: 1702

This can happen if the origin of the image is not at 0,0. In that case, using +repage before processing the image should do the trick, i.e.

convert WBS.png +repage -crop 256x256 +repage +adjoin output\WBS_%02d.jpg

See also the documentation of the -crop option.

Upvotes: 5

Related Questions