chop with percentage affects other dimension

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
muccigrosso
Posts: 64
Joined: 2017-10-03T10:39:52-07:00
Authentication code: 1151

chop with percentage affects other dimension

Post 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
Last edited by muccigrosso on 2017-10-03T14:02:10-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: chop with percentage affects other dimension

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: chop with percentage affects other dimension

Post 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.
muccigrosso
Posts: 64
Joined: 2017-10-03T10:39:52-07:00
Authentication code: 1151

Re: chop with percentage affects other dimension

Post 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. :(
Post Reply