Page 1 of 1

[Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-08T18:48:27-07:00
by plug.gulp@gmail.com
Hi,

I am new to ImageMagick. I am using MagickWand for my development. My project requires generating images on the fly in memory (and then doing some image processing on them). I am using bezier curve primitive to draw on the image canvas. All the control points are generated at runtime. I want to now set various clipping paths to this image. Is there a way to do this using MagickWand or MagickCore? The DrawSetClipPath API is used to select/activate an already available clipping path within the image. What I want is to be able to actually set the clipping paths first into the image and then during further rendering, select/activate one of the clipping paths that I set earlier. Is this possible using IM's C APIs? I searched this forum and on internet but was not able to find any answer.

Thanks and regards,

~Plug

Re: [Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-10T16:34:17-07:00
by anthony
Yes their is . Some examples are around, Especially from El Supremo.
http://members.shaw.ca/el.supremo/MagickWand/

Re: [Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-10T17:31:44-07:00
by el_supremo
Thanks for the reference Anthony.
Unfortunately, the only example I have uses a clip mask not a clip path.
There is a program called drawtest.c in the MagickWand directory of the svn code which sets a clipping path but I haven't tried it out yet to see how it works.

Pete

Re: [Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-10T19:33:42-07:00
by anthony
Clip Paths essentially generate Clips Masks (actually 'write masks')

See IM Examples, for command line equivalents
http://www.imagemagick.org/Usage/masking/#write_mask

These should be in MagickWand too.
Just a matter of finding the function names.

Re: [Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-11T14:56:51-07:00
by plug.gulp@gmail.com
Thank you Anthony and El Supremo!

I looked at the drawtest file and now I understand how to create and set custom clip path using MagickWand.

I am listing the code snippet from the drawtest file (file is at <Magick source dir>/wand/drawtest.c) for others who might be interested:
(the source code can be downloaded from http://imagemagick.org/script/install-source.php)

Code: Select all

/*+++++++++++++++++++++++++++++++++++++++++++++*/
/* Definition of a clip path */
    DrawPushDefs(picasso);
    {
      DrawPushClipPath(picasso,"clip_1");
      {
        (void) PushDrawingWand(picasso);
        {
          DrawRectangle(picasso,0,0,595.3,841.9);
        }
        (void) PopDrawingWand(picasso);
      }
      DrawPopClipPath(picasso);
    }
    DrawPopDefs(picasso);


    (void) PushDrawingWand(picasso);
    {
      /* Use of the clip path defined above */
      (void) DrawSetClipPath(picasso, "url(#clip_1)");

      /* Other drawing functions */
    }
    (void) PopDrawingWand(picasso);
/*+++++++++++++++++++++++++++++++++++++++++++++*/
Thanks once again for your help.

Kind regards,

~Plug

Re: [Newbie] MagickWand, ClipPath and dynamic image...

Posted: 2012-05-11T15:02:47-07:00
by fmw42
It is nice to have this kind of feedback from users. I am sure the noted people will be pleased that you solved your problem.