Hi,
Can we do the same thing with a script ?
Can we do the same thing with a script ?
// Magick.NET understands the ~ prefix.
var first = new MagickImage(@"~\files\house.jpg");
var second = new MagickImage(@"~\files\monkey.jpg");
double[] args =
{
// Move 0x0 to 105x54
0,0, 105,54,
// Move 0x120 to 105x152
0,second.Height, 105,152,
// Move 180x0 to 163x76
second.Width,0, 163,76,
// Move 180x120 to 163x122
second.Width,second.Height, 163,122
};
// Extend the second image if it does not fit in the first image.
if (second.Height < first.Height || second.Width < first.Width)
{
second.BackgroundColor = MagickColor.Transparent;
second.Extent(first.Width, first.Height);
}
// Perform the distortion.
second.HasAlpha = true;
second.VirtualPixelMethod = VirtualPixelMethod.Transparent;
second.Distort(DistortMethod.Perspective, args);
// Draw second image on top of first image.
first.Composite(second, Gravity.Northwest, CompositeOperator.SrcOver);
first.Write(@"~\files\house_with_paint.jpg");