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

New Post: Question about composite command and images of different sizes

$
0
0
Your image is not Resized to the specified width and height because it will maintain aspect ratio. When the image is drawn on top it will make the 'unknown' part black. Settings the background to Transparent and using the Extent method should solve your problem.
using (MagickImage image = new MagickImage("example.jpg"))
{
  using (MagickImage watermark = new MagickImage("watermark.png"))
  {
    //resize watermark to fit the proof image
    watermark.Resize(image.Width, image.Height);
    watermark.BackgroundColor = MagickColor.Transparent;
    watermark.Extent(image.Width, image.Height);

    image.Composite(watermark, Gravity.Center, CompositeOperator.Dissolve, "11");
    image.Write("examplewatermarked.png");
  }
}

Viewing all articles
Browse latest Browse all 3693

Trending Articles