This project has moved. For the latest updates, please go here.

Get Only Diff

May 16, 2016 at 11:25 AM
Hi,

Could anyone please help me in getting the same result in the .Net code as the one below from command prompt?

composite.exe D:\test\image1.png D:\test\image2.png -compose difference Src D:\test\diff.png
convert.exe D:\test\diff.png -alpha copy D:\test\result.png
Coordinator
May 16, 2016 at 4:17 PM
Your command would translate to this:
using (MagickImage image1 = new MagickImage(@"D:\test\image1.png"))
{
  using (MagickImage image2 = new MagickImage(@"D:\test\image2.png"))
  {
    image1.Composite(image2, CompositeOperator.Difference); // this is now diff.png

    image1.Alpha(AlphaOption.Copy);

    image1.Write("@D:\test\result.png");
  }
}
I don't understand the extra 'Src' in your command it gives me a command line error.
May 17, 2016 at 7:09 AM
Thanks a lot for your help. :)
May 19, 2016 at 6:41 AM
Hi dlemstra,

Thanks again for the earlier help, I would like to know if I had done this right or not.
The below code which is done through command prompt is done this way.

compare.exe -metric AE -fuzz 7.5% D:\test\image1.jpg D:\test\image2.jpg D:\test\result.jpg

So, is the below code what I have written is similar to the one above?
using (MagickImage image1 = new MagickImage(@"D:\test\image1.png"))
{
  using (MagickImage image2 = new MagickImage(@"D:\test\image2.png"))
  {
                    using (MagickImage diffImage = new MagickImage())
                    {
                        image1.ColorFuzz = new ImageMagick.Percentage(7.5);
                        image2.ColorFuzz = new ImageMagick.Percentage(7.5);
                        image1.Compare(image2, ErrorMetric.Absolute, diffImage);
                        diffImage.Write("@D:\test\result.png");
                    }
}
}
Coordinator
May 19, 2016 at 4:59 PM
Your translation is correct but you will only need to set the color fuzz on image1.
May 20, 2016 at 11:43 AM
Okay. Thanks i will do that.