Page 1 of 1

chop with percentage affects other dimension

Posted: 2017-10-03T11:19:52-07:00
by muccigrosso
If I use -chop with a percentage in only one dimension, the second dimension loses a pixel too. For example (and here I'm chopping the width, but the results are the same if I use the height):

Code: Select all

convert -format "%w x %h" rose: info:
yields: 70 x 46

Code: Select all

convert -format "%w x %h" -gravity east -chop 1x0 rose: info:
yields the expected 69 x 46, but

Code: Select all

convert -format "%w x %h" -gravity east -chop 1%x0 rose: info:
yields 69 x 45.

Why is the height getting chopped too?

It looks like even with a 0% chop, 1 pixel is always removed, as long as there's a percentage and not a number of pixels:

Code: Select all

convert rose: -format "%w x %h" -gravity east -chop 0%x0 info:
yields the same 69 x 45.

Version: ImageMagick 7.0.7-5 Q16 x86_64 2017-10-03 http://www.imagemagick.org
Mac OS X 10.11.6

Re: chop with percentage affects other dimension

Posted: 2017-10-03T12:36:20-07:00
by snibgo
What version of IM? Please ALWAYS state the version of IM.

I can't find the thread, but a change was made recently, so that when a "%" was used in geometry, any result of zero was changed to one. This was to prevent "-resize 1%" etc from failing by trying to create an image of zero pixels.

I suspect that change has caused this problem.

Re: chop with percentage affects other dimension

Posted: 2017-10-03T13:17:37-07:00
by GeeMack
snibgo wrote: 2017-10-03T12:36:20-07:00I suspect that change has caused this problem.
Using ImageMagick 7.0.7-5 on Windows and running this command with the 640x480 built-in logo:...

Code: Select all

magick logo: -chop 0x0% info:
The output shows a single row of pixels has been chopped from both the width and height...

Code: Select all

logo: GIF 639x479 639x479+0+0 8-bit sRGB 256c 0.016u 0:00.004
Running the same command with a bit older ImageMagick 6.9.8-10 and "convert" produces the expected output showing "logo:" with the original 640x480 dimensions.

Re: chop with percentage affects other dimension

Posted: 2017-10-03T14:04:02-07:00
by muccigrosso
snibgo wrote: 2017-10-03T12:36:20-07:00 What version of IM? Please ALWAYS state the version of IM.

I can't find the thread, but a change was made recently, so that when a "%" was used in geometry, any result of zero was changed to one. This was to prevent "-resize 1%" etc from failing by trying to create an image of zero pixels.

I suspect that change has caused this problem.
Sorry. Version added above.

And yes, that would do it! Guess I'll have to calculate the number of pixels then. :(