如何通过ImageMagick处理图像的一部分? [英] How to process only one part of image by ImageMagick?

查看:134
本文介绍了如何通过ImageMagick处理图像的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下图像,我想在它上面创建一个扭曲效果。但只是图像的一部分,而不是整个图像。

I have an image like below and I want to create a distort effect on it. But just the one part of image, not the whole image.

谢谢。

推荐答案

我假设您使用的是Magick.NET( https://magick.codeplex.com ),因为您添加了C#标签。

I am assuming you are using Magick.NET (https://magick.codeplex.com) because you added the C# tag.

下面的示例将首先剪切出图像的前123个像素并对其应用失真。失真后,它必须放在源图像的顶部。

The example below will first cut out the top 123 pixels of your image and applies a distortion to it. After the distortion it will have to be put on top of the source image.

using (MagickImage image = new MagickImage("0nF6D.png"))
{
  using (MagickImage top = image.Clone())
  {
    top.Crop(image.Width, 123, Gravity.North);
    top.Distort(DistortMethod.ScaleRotateTranslate, new double[] { 2, 45 });
    image.Composite(top, Gravity.North, CompositeOperator.SrcOver);
    image.Write("0nF6D.distorted.png");
  }
}

这篇关于如何通过ImageMagick处理图像的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆