spurious -crop results (bug or feature?)

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
bablokb
Posts: 29
Joined: 2005-06-11T06:21:59-07:00

spurious -crop results (bug or feature?)

Post by bablokb »

Hi,

I get different results using the following two convert-commands:

Code: Select all

convert img1.jpg -resize x1535 -crop 1062x1535 -border 5 \( \
           img2.jpg -resize x1535 -crop 1062x1535 -border 5 \) \
             +append test.img
and

Code: Select all

convert img1.jpg -resize x1535 -crop 1062x1535+0+0 -border 5 \( \
           img2.jpg -resize x1535 -crop 1062x1535+0+0 -border 5 \) \
             +append test.img
The first command shows four "tiles" (i.e. the cropped images plus the strips which should have been cropped off), the second command shows the expected result (two tiles of the cropped images).

N.B.: adding +repage does not make a difference. Splitting the first command into three commands (cropping, cropping, appending) gives the same result as the second command.

Can anybody explain if this is a bug or a subtle feature of -crop?

I'm using IM version 6.3.5 Q16 running on openSUSE 10.3.


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

Re: spurious -crop results (bug or feature?)

Post by anthony »

Of course it has different results!!!!!

Not specifying a crop position (such as leaving off the with "+0+0") means you want to tile crop the image into multiple sections or tiles. See IM Examples,
Tile Cropping, sub-dividing one image into multiple images

Note you could also just read both images in then resize and crop each image. Most IM commands are just applied to all images in the current image sequence.

Code: Select all

convert img1.jpg img2.jpg \
            -resize x1535 -crop 1062x1535+0+0 -border 5 \
             +append test.img
Also if you have the very latest IM you may be interested in the new '^' flag for resizing/crop type operations. Also see IM Examples, Resize section. Or the Thumbnail section on the same technique, Cut image to fit
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply