问题
I have 3 images: source.jpg, saturated.jpg and mask.jpg, I want to blend the source.jpg and saturated.jpg using the mask.jpg.
When I use the ImageMagick's convert command:
convert source.jpg saturated.jpg mask.jpg -compose over -composite result.jpg
I get this result.
But when I do the same with Magick++:
Magick::Image source,saturated,mask;
source.read("source.jpg");
saturated.read("saturated.jpg");
mask.read("mask.jpg");
source.clipMask(mask);
source.composite(saturated,0,0,OverCompositeOp);
I get this result.
Can someone please tell me what I am doing wrong?
回答1:
This gets pretty close to the command line version:
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
InitializeMagick(*argv);
Magick::Image source,saturated,mask;
source.read("source.jpg");
saturated.read("saturated.jpg");
mask.read("mask.jpg");
mask.type( Magick::GrayscaleType );
mask.negate();
source.mask(mask);
source.composite(saturated,0,0,OverCompositeOp);
source.write("mppresult.jpg");
}
来源:https://stackoverflow.com/questions/34329954/imagemagick-result-differ-from-magick