Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Working with clipping paths

$
0
0
I decided to put my answer in code and comments. Feel free to ask if you need more info.
/* specifying the density befor reading will resolve your size issue */
MagickReadSettings settings = new MagickReadSettings()
{
  Density = new Density(96)
};

using (MagickImage image = new MagickImage("34667.eps", settings))
{
  /* first create a color (make sure it is CMYK when your input image is) */
  MagickColor color = new ColorCMYK(0, Quantum.Max, 0, 0);

  /* the following constructors will be available in the next release */// color = new ColorCMYK("#45D10000");// color = new ColorCMYK((Percentage)27, (Percentage)82, (Percentage)0, (Percentage)0);/* this works for me */// image.Clip("Pfad 1", true);// image.FloodFill(color, 0, 0);/* but this is better */
  image.Clip("Pfad 1", false);
  using (MagickImage background = new MagickImage(color, image.Width, image.Height))
  {
    /* the clipping part makes sure only the pixels you want to be changed are changed */
    image.Composite(background, CompositeOperator.In);

    /* this will work in the next release */// image.Composite(background);
  }

  image.Write("output.png");
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles