Page 2 of 2

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-02T16:08:41-07:00
by fmw42
magick wrote:The patch is available now. Give it a try.
I downloaded ImageMagick-6.7.8-8.tar.bz2 02-Aug-2012 14:47, but do not see what I would have expected. Perhaps it has not made it into the available beta at this time.

Here are my tests and what I would like to see happen, which depends upon whether an "x" is specified. It gives the most flexible options that I can think of.

For pixel units:
1) if one value and no x, apply the pixel value equally to W and H [this would then be the same as 3) below]
2) if one value and x supplied, then apply the pixel value only to W or H dimension specified with the x
3) if two values (separate by x), then apply those pixel values separately to W and H


imb convert -size 100x300 xc:white -bordercolor black -border 5 -format "%w x %h" info:
110 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x -format "%w x %h" info:
110 x 310 --> this would then become 110x300 so similar in behavior to x5 just below

imb convert -size 100x300 xc:white -bordercolor black -border x5 -format "%w x %h" info:
100 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x5 -format "%w x %h" info:
110 x 310 --> this is correct


For percent units:
1) if one value and no x, convert the given percent to pixels separately for W and H and apply to each dimension appropriately [this would then be the same as 3) below]
2) if one value and x supplied, convert the percent to pixels using the given dimensions specified by the x and apply that pixel value to both dimension.
3) if two values (separate by x), convert the given percents to pixels separately for W and H and apply to each dimension appropriately

imb convert -size 100x300 xc:white -bordercolor black -border 5% -format "%w x %h" info:
110 x 330 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x% -format "%w x %h" info:
110 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border x5% -format "%w x %h" info:
300 x 330 -- this should be 130 x 330 so similar in behavior to 5x% just above

imb convert -size 100x300 xc:white -bordercolor black -border 5x5% -format "%w x %h" info:
110 x 330 -- this is correct


Alternately, make 5 and 5x be the same as 5x above and similarly 5% and 5x% be the same as 5x% above.

Anthony and Draoidh, what do you guys think?

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-02T19:06:52-07:00
by magick
  • convert -size 100x300 xc:white -bordercolor black -border x5% -format "%w x %h" info:
    300 x 330 -- this should be 130 x 330 so similar in behavior to 5x% just above
This problem is fixed in the latest Beta, building now. We're not sure it make sense to extend this behavior to non-percent geometries with missing values. If Anthony feels otherwise, we'll add a patch to treat non-percent geometries the same as percent geometries.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-02T19:18:52-07:00
by anthony
I'll take a look at this tonight.

UPDATE, after "magick"s post....
The problem is only with percent figures. Howver making "5x" to also add 5 to height may not be fully backward compatible, though it is sensible.

Normal handling is for missing values to have a value of zero. Now if '%' then use percentage of the other dimension.
Really the question becomes....

If 5%x adds 5% of width to BOTH width and height,
and x5% adds 5% of height to both width and height
then what does 5x and x5 do? previously this added 0 borders to the other dimension!

How confused do you want this?


PS: IMv7 allows you to use % escapes and %[fx:..] formulas to operation arguments (and soon to setting arguments). As such really this problem may become moot for IMv7. So...

Do we want this confusing complication?
It is probably better to leave it simple. and use IMv7 escapes.
And yes I know I suggest this originally! I am just having second thoughts.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-02T21:52:35-07:00
by fmw42
If 5%x adds 5% of width to BOTH width and height,
and x5% adds 5% of height to both width and height
then what does 5x and x5 do? previously this added 0 borders to the other dimension!
What I was suggesting above is:

For pixel units:
1) if one value and no x, apply the pixel value equally to W and H [this would then be the same as 3) below]
2) if one value and x supplied, then apply the pixel value only to W or H dimension specified with the x
3) if two values (separate by x), then apply those pixel values separately to W and H


imb convert -size 100x300 xc:white -bordercolor black -border 5 -format "%w x %h" info:
110 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x -format "%w x %h" info:
110 x 310 --> this would then become 110x300 so similar in behavior to x5 just below

imb convert -size 100x300 xc:white -bordercolor black -border x5 -format "%w x %h" info:
100 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x5 -format "%w x %h" info:
110 x 310 --> this is correct

Thus the only change is to make 5x behave similar to x5. Thus it would add 5 pixels only to left and right. So that it is similar to x5 which currently adds 5 pixels only to top and bottom

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-03T09:56:11-07:00
by fmw42
OK testing with the latest beta shows that the % work fine now. That is x5% works similarly to 5x%

But the 5x does not behave similarly to x5 for pixels.

I would have liked to see:


For pixel units:
1) if one value and no x, apply the pixel value equally to W and H [this would then be the same as 3) below]
2) if one value and x supplied, then apply the pixel value only to W or H dimension specified with the x
3) if two values (separate by x), then apply those pixel values separately to W and H


imb convert -size 100x300 xc:white -bordercolor black -border 5 -format "%w x %h" info:
110 x 310 --> this is correct

imb convert -size 100x300 xc:white -bordercolor black -border 5x -format "%w x %h" info:
110 x 310 --> this would then become 110x300 so similar in behavior to x5 just below

imb convert -size 100x300 xc:white -bordercolor black -border x5 -format "%w x %h" info:
100 x 310 --> this is correct -- it only adds to the H

imb convert -size 100x300 xc:white -bordercolor black -border 5x5 -format "%w x %h" info:
110 x 310 --> this is correct


I would suggest that 5x be made to work similarly to x5. So change one or the other so they are consistent one way or the other.

Either make 5x add only to W so similar to x5 which adds only to H. Or make 5x and x5 behave like 5 or 5x5 so they all add to W and H.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-03T12:34:07-07:00
by magick
Grab the latest ImageMagick 6.7.8-8 Beta (building now). Let us know if -border is behaving as expected.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-03T17:10:41-07:00
by fmw42
magick wrote:Grab the latest ImageMagick 6.7.8-8 Beta (building now). Let us know if -border is behaving as expected.
OK. It works consistently now. Thanks for the changes. I will write something in the -border docs on the options page over the weekend to explain all the combinations.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-20T13:19:19-07:00
by yanca
The behavior will remain intact then. A single percent argument specifies a width and height as a percentage of the width. Two values specifies a percent width and a percent height border.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-08-20T14:48:31-07:00
by fmw42
yanca wrote:The behavior will remain intact then. A single percent argument specifies a width and height as a percentage of the width. Two values specifies a percent width and a percent height border.

See the new documentation at http://www.imagemagick.org/script/comma ... php#border. The table shows what happens for each option. Let us know if there is any discrepancies.

Re: possible bug in -border X% in IM 6.7.8.6 Q16

Posted: 2012-09-29T16:08:20-07:00
by Draoidh
Just in case anyone else gets caught out by the slightly changed percentage border behaviour:
magick wrote:The behavior will remain intact then. A single percent argument specifies a width and height as a percentage of the width.
I just installed version 6.7.9-8 2012-09-29 Q16 and I am finding the behaviour has changed slightly:

Code: Select all

convert c.png -border 5% cborder.png
A 400x300 image turns into 440x330.

To retain the same behaviour, the border geometry needs to be specified as "5%x"

Code: Select all

convert c.png -border 5%x cborder.png
That seems to be a good way of providing all the options and the docs are uptodate.