Page 1 of 1
-gravity documentation
Posted: 2017-06-30T07:19:50-07:00
by snibgo
http://www.imagemagick.org/script/comma ... hp#gravity correctly says the default is "undefined", but doesn't say that "+gravity" can be used to set the default gravity.
Please add a note about "+gravity". Thanks.
Re: -gravity documentation
Posted: 2017-06-30T09:14:54-07:00
by fmw42
I do not understand the default "undefined". It seems to me that the default is northwest.
Re: -gravity documentation
Posted: 2017-06-30T09:53:47-07:00
by snibgo
"-gravity undefined" and "-gravity northwest" are similar but not always identical. Consider three cases (tested with v6.9.5-3):
Code: Select all
convert -size 300x100 xc: -pointsize 50 -annotate +0+20 "Hy" gravtest_null.png
Code: Select all
convert -size 300x100 xc: -gravity Undefined -pointsize 50 -annotate +0+20 "Hy" gravtest_und.png
Code: Select all
convert -size 300x100 xc: -gravity Northwest -pointsize 50 -annotate +0+20 "Hy" gravtest_nw.png
Re: -gravity documentation
Posted: 2017-06-30T10:03:00-07:00
by fmw42
snigbo: Thanks for the clarification. It seems to be the case when placing text. But it looks to me that they are the same for -composite as per:
Code: Select all
convert logo: rose: -compose over -composite logo_rose_und.jpg
Code: Select all
convert logo: rose: -gravity northwest -compose over -composite logo_rose_nw.jpg
And I also think they are the same for -crop.
So perhaps this should also be made clear in the docs, if this is indeed true.
Re: -gravity documentation
Posted: 2017-06-30T11:11:04-07:00
by snibgo
Crop with a percentage, no offsets, and no gravity:
Code: Select all
f:\web\im>%IM%convert rose: -crop 20x20% info:
rose:[0] PPM 14x9 70x46+0+0 8-bit sRGB 0.000u 0:00.000
rose:[1] PPM 14x9 70x46+14+0 8-bit sRGB 0.016u 0:00.016
rose:[2] PPM 14x9 70x46+28+0 8-bit sRGB 0.016u 0:00.016
rose:[3] PPM 14x9 70x46+42+0 8-bit sRGB 0.016u 0:00.016
rose:[4] PPM 14x9 70x46+56+0 8-bit sRGB 0.016u 0:00.016
rose:[5] PPM 14x9 70x46+0+9 8-bit sRGB 0.016u 0:00.016
rose:[6] PPM 14x9 70x46+14+9 8-bit sRGB 0.016u 0:00.016
rose:[7] PPM 14x9 70x46+28+9 8-bit sRGB 0.016u 0:00.016
rose:[8] PPM 14x9 70x46+42+9 8-bit sRGB 0.016u 0:00.016
rose:[9] PPM 14x9 70x46+56+9 8-bit sRGB 0.016u 0:00.016
rose:[10] PPM 14x9 70x46+0+18 8-bit sRGB 0.031u 0:00.031
rose:[11] PPM 14x9 70x46+14+18 8-bit sRGB 0.031u 0:00.031
rose:[12] PPM 14x9 70x46+28+18 8-bit sRGB 0.031u 0:00.031
rose:[13] PPM 14x9 70x46+42+18 8-bit sRGB 0.031u 0:00.031
rose:[14] PPM 14x9 70x46+56+18 8-bit sRGB 0.031u 0:00.031
rose:[15] PPM 14x9 70x46+0+27 8-bit sRGB 0.031u 0:00.031
rose:[16] PPM 14x9 70x46+14+27 8-bit sRGB 0.031u 0:00.031
rose:[17] PPM 14x9 70x46+28+27 8-bit sRGB 0.031u 0:00.031
rose:[18] PPM 14x9 70x46+42+27 8-bit sRGB 0.047u 0:00.047
rose:[19] PPM 14x9 70x46+56+27 8-bit sRGB 0.047u 0:00.047
rose:[20] PPM 14x9 70x46+0+36 8-bit sRGB 0.047u 0:00.047
rose:[21] PPM 14x9 70x46+14+36 8-bit sRGB 0.047u 0:00.047
rose:[22] PPM 14x9 70x46+28+36 8-bit sRGB 0.047u 0:00.047
rose:[23] PPM 14x9 70x46+42+36 8-bit sRGB 0.047u 0:00.047
rose:[24] PPM 14x9 70x46+56+36 8-bit sRGB 0.047u 0:00.047
rose:[25] PPM 14x1 70x46+0+45 8-bit sRGB 0.047u 0:00.047
rose:[26] PPM 14x1 70x46+14+45 8-bit sRGB 0.063u 0:00.063
rose:[27] PPM 14x1 70x46+28+45 8-bit sRGB 0.063u 0:00.063
rose:[28] PPM 14x1 70x46+42+45 8-bit sRGB 0.063u 0:00.063
rose:[29] PPM 14x1 70x46+56+45 8-bit sRGB 0.063u 0:00.063
"-gravity Undefined" returns the same result. But NorthWest gives us only one output:
Code: Select all
f:\web\im>%IM%convert rose: -gravity NorthWest -crop 20x20% info:
rose: PPM 14x9 70x46+0+0 8-bit sRGB 0.000u 0:00.000
With a percentage (%) in the crop and no offsets, supplying any real gravity gives us just one image. But supplying no gravity, or "Undefined", we get multiple images.
Looking at the code (in geometry.c and transform.c) this looks deliberate, not a bug.
My own rule of thumb is: when I care about the gravity, I specify it.