Menu

#15 How do I set Gravity using MagickTransformImage()

v1.0_(example)
closed
None
5
2014-01-05
2014-01-01
RNHurt
No

I'm trying to use MagickTransformImage() from the image wand API and I can't seem to find a way to set the gravity or offset. I tried playing around with the geometry string and crop string but that didn't help at all. I see that ImageMagick has a MagickSetImageGravity() that they use before crop operations to set the gravity and was wondering if GM has something like that as well.

I'm pretty new to GM programming so I may be doing something completely wrong. :O

Thanx!
Richard

Discussion

  • Bob Friesenhahn

    Bob Friesenhahn - 2014-01-01

    There are a few missing accessors for image attributes. I believe that MagickSetImagePage() will set image offsets (but is not what you want to use). Someone else already complained a few days ago that there is no way to set the gravity. I will probably work on adding functions (i.e. MagickSetImageGravity()) to set the image gravity today.

    I am not sure how either of the above relate to MagickTransformImage() since this function seems to accept all of the arguments that it uses. C programmers are able to do the math (based on current image dimensions) to compute the crop and geometry strings used as arguments. The crop string is in the form WIDTHxHEIGHT+Xoffset+Yoffset (see the command-line documentation for -page) so it does include offset information. The notion of gravity is more important to command line users since they often do not know the size of the image and depend on automatic computations.

     
  • RNHurt

    RNHurt - 2014-01-01

    You are absolutely correct. After posting this I realized that I was trying to do something that I really didn't need to do. However, I would be most appreciative for some Gravity functionality in the wand API where it makes sense.

    Thanx!
    Richard

    BTW: I'm building a Ruby layer to the Wand API (https://github.com/rnhurt/ffi-gmagick) which is driving these questions. :)

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2014-01-01

    A Ruby layer sounds great! Previously there was RMagick but it has fallen out of maintenance.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2014-01-05
    • status: open --> closed
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2014-01-05

    GraphicsMagick 1.3.20 will have a MagickSetImageGravity() function, and this change is already in Mercurial. Thanks for bringing this to my attention.

     

Log in to post a comment.

MongoDB Logo MongoDB