How to add mask in magickhand (php)
How to add mask in magickhand (php)
Hi,
1, I imported image
2, created a rectangle with rounded edges
Now, I would like to use the rectangle as a mask.
How may I do that using magickwand?
There is a matte command....when doing that via command line, but not sure how to do it here.
Please help.
Paul
1, I imported image
2, created a rectangle with rounded edges
Now, I would like to use the rectangle as a mask.
How may I do that using magickwand?
There is a matte command....when doing that via command line, but not sure how to do it here.
Please help.
Paul
The following discussion of extracting a mask using the command line should help you see some techniques:
http://www.cit.gu.edu.au/~anthony/graph ... s/#extract
The last technique (colorize then flatten) looks especially easy. I don't know how to translate any of it into MagickWand for PHP.
http://www.cit.gu.edu.au/~anthony/graph ... s/#extract
The last technique (colorize then flatten) looks especially easy. I don't know how to translate any of it into MagickWand for PHP.
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
I don't know how to do this in PHP and I haven't used that specific technique in C, but I think the command you need will look something like this C function:
where magick_wand is the imported image and mask_wand is, of course, the mask image. The 0,0 on the end is the x,y offset coordinates.
Pete
Code: Select all
MagickCompositeImage(magick_wand,mask_wand,DstOutCompositeOp,0,0);
Pete
Yes, that's gotta be it...doesn't seem to work though, I tried following..and all I got is the picture.
I use following script:
IM_fileopen('../../tmp/1b.jpg'); (my function)
DrawRectangle($dwand, 50, 50, 100, 100);
DrawSetFillColor($dwand,$pwand);
$width = MagickGetImageWidth($resource);
$height = MagickGetImageHeight($resource);
DrawComposite($dwand, MW_DstOutCompositeOp, 0, 0, $width, $height, $resource);
IM_output("JPG"); (my function)
Any idea?
I use following script:
IM_fileopen('../../tmp/1b.jpg'); (my function)
DrawRectangle($dwand, 50, 50, 100, 100);
DrawSetFillColor($dwand,$pwand);
$width = MagickGetImageWidth($resource);
$height = MagickGetImageHeight($resource);
DrawComposite($dwand, MW_DstOutCompositeOp, 0, 0, $width, $height, $resource);
IM_output("JPG"); (my function)
Any idea?
ok...fixed it, but all I see is a black square on the image:
IM_fileopen('../../tmp/1b.jpg');
MagickSetSize($resource2, 100, 100);
MagickReadImage($resource2, "xc:none");
DrawRectangle($dwand, 50, 50, 100, 100);
DrawSetFillColor($dwand,$pwand);
MagickDrawImage($resource2,$dwand);
MagickCompositeImage($resource, $resource2, MW_DstOutCompositeOp, 0, 0);
IM_output("JPG");
IM_fileopen('../../tmp/1b.jpg');
MagickSetSize($resource2, 100, 100);
MagickReadImage($resource2, "xc:none");
DrawRectangle($dwand, 50, 50, 100, 100);
DrawSetFillColor($dwand,$pwand);
MagickDrawImage($resource2,$dwand);
MagickCompositeImage($resource, $resource2, MW_DstOutCompositeOp, 0, 0);
IM_output("JPG");
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: How to add mask in magickhand (php)
Oh man, how I hate those guys telling you they figured something out.... as if it would interest anybody.
Either someone knows better then you.... then he doesn't care.
Or he doesn't know better.... then he doesn't care, too.
I mean whats the stupid meaning of this sentence when there's no solution next to it.
That's something one could care about. Grrrr
<=== don't take this to serious
Either someone knows better then you.... then he doesn't care.
Or he doesn't know better.... then he doesn't care, too.
I mean whats the stupid meaning of this sentence when there's no solution next to it.
That's something one could care about. Grrrr
<=== don't take this to serious