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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
plug.gulp@gmail.com
Posts: 3
Joined: 2012-05-08T17:45:36-07:00
Authentication code: 13

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

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

Yes their is . Some examples are around, Especially from El Supremo.
http://members.shaw.ca/el.supremo/MagickWand/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

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

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
plug.gulp@gmail.com
Posts: 3
Joined: 2012-05-08T17:45:36-07:00
Authentication code: 13

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Post Reply