Using "-chop" with percentages in IM 7.0.7-6

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Using "-chop" with percentages in IM 7.0.7-6

Post by GeeMack »

Following up on an issue discussed at this LINK. Using IM 7.0.7-6 on Windows 10, creating a 640x480 built-in "logo:", and using "-chop" to remove some percentages with this command...

Code: Select all

magick logo: -chop "5%x0%" info:
The output specs show an image which is 608 pixels wide as expected, but it's 479 pixels high. It should chop nothing in the "0%" direction and remain 480 pixels, but it chops one row anyway.

Also, when using "-chop" with an inline FX expression to set the percentages to chop, the command fails to chop either width or height. Running this command...

Code: Select all

magick logo: -chop "%[fx:1+2]%x%[fx:3+4]%" info:
... describes an output image of 640x480, same as the input. It should chop 3% from the width and 7% from the height, but it doesn't chop anything at all.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Using "-chop" with percentages in IM 7.0.7-6

Post by GeeMack »

This issue remains with version 7.0.7-7 Q16 HDRI using Windows 10 64. This command...

Code: Select all

magick logo: -chop 0%x0% info:
Produces this output...

Code: Select all

logo: GIF 639x479 639x479+0+0 8-bit sRGB 256c 0.016u 0:00.006
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using "-chop" with percentages in IM 7.0.7-6

Post by fmw42 »

I think IM tries to chop at least one pixel in either dimension as a minimum. If you wanted 0 pixel chop, that would be a no-op and why bother calling -chop? Trying to chop 0 pixels in one dimension does not make sense to me. That means that one whole row or column is not going to be chopped since the one dimension is 0. So again a no-op situation.

Have I misunderstood some other situation where this makes more sense? Or are you just looking for it to do nothing if either dimension is 0%, which you could do by a conditional test beforehand.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using "-chop" with percentages in IM 7.0.7-6

Post by snibgo »

"-chop WxH" should remove W columns, and also remove H rows. This might be zero columns, and 5 rows. Zero does make sense.

Code: Select all

convert rose: +write info: -chop 0x5 info:
In v6.9.5-3, this produces the expected output:

Code: Select all

rose: PPM 70x46 70x46+0+0 8-bit sRGB 0.000u 0:00.000
rose: PPM 70x41 70x41+0+0 8-bit sRGB 0.000u 0:00.000
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using "-chop" with percentages in IM 7.0.7-6

Post by fmw42 »

Thanks, snibgo. I stand corrected. I was misinterpreting what W and H mean in -chop.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Using "-chop" with percentages in IM 7.0.7-6

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.
Post Reply