Page 1 of 1

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

Posted: 2017-10-05T19:18:44-07:00
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.

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

Posted: 2017-10-08T11:34:43-07:00
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

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

Posted: 2017-10-09T15:43:02-07:00
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.

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

Posted: 2017-10-09T16:13:43-07:00
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

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

Posted: 2017-10-09T16:16:18-07:00
by fmw42
Thanks, snibgo. I stand corrected. I was misinterpreting what W and H mean in -chop.

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

Posted: 2017-10-09T16:45:12-07:00
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.