Page 1 of 1

set gravity

Posted: 2011-07-27T15:48:58-07:00
by docjones2

I have read in various places that the msl language hasn't implemented all the features of PerlMagick yet, because of lack of demand -- however that features would implemented upon request "usually within a day."

There is currently no way to set gravity (ie: <set gravity='Center'/> ), which I need the ability to do.

I am using imagemagick 6.7 latest stable build, compiling source and running on various linux computers. I scoped msl.c and indeed gravity is not implemented in <set>

Thank you!

Re: set gravity

Posted: 2011-07-27T16:58:49-07:00
by magick
We have a patch in ImageMagick 6.7.1-1 beta (available sometime tomorrow) to fix the problem you reported. Thanks.

Re: set gravity

Posted: 2011-07-28T09:47:54-07:00
by docjones2
Thank you!

I imagine the code will be available at , no?

I'll give it a whirl and post back on the status.

Re: set gravity

Posted: 2011-07-28T10:17:29-07:00
by docjones2
It seems as if gravity is recognized now as a <set> option, however I'm not sure if it works correctly.

Consider the following

Code: Select all

<set gravity='Center' />
<crop geometry='250x250+0+0'/>
This doesn't seem to do what is expected, which (if I understand correctly) should be the equivalent of

Code: Select all

convert filename -gravity Center -crop 250x250+0+0 outname
If this assumption reflects my misunderstanding, how can I achieve a crop with gravity?

I have seen other tags (like composite) which support a gravity attribute, but crop does not.

Re: set gravity

Posted: 2011-07-28T11:11:29-07:00
by docjones2
I figured it out.

at msl.c line 2141 there is the function call

Code: Select all

changing this to

Code: Select all

will give the behaviour I expected, and fixes my issue.

Of course, I am no imagemagick developer and I haven't even ever used PerlMagick, so I do not know whether or not I am breaking any rules or going against an earlier decision to implement <crop> in this way, but it does what I want.

Post back with any comments or insights or reprimands!

On a side note, convert -crop calls CropImageToTiles as opposed to CropImage, so my change does not exactly mimic the command line behaviour 1:1, but it comes close for my purposes. I'm not sure how msl would handle tiling behaviour anyway.


EDIT: This fix will not work if attributes height, width, x, y are used instead of geometry. Trying to fix that now.

Re: set gravity

Posted: 2011-07-28T21:41:34-07:00
by anthony
There are two composition methods used for placement of images.
gravity and a geometry offset (set using -gravity and -geometry)
virtual canvas offsets. (set using -page and -repage)

They are rarely used together.

Be sure you are not changing something that should not be changed!