image masking effect.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
ncm123

image masking effect.

Post by ncm123 »

Image
Image
Image

Hi,

I am trying to get this effect done. where user uploads image 1, then i process and generate- image 3.

How to do this? Can anyone help!

Thanks!
emery

Re: image masking effect.

Post by emery »

Roughly

Code: Select all

$draw = new ImagickDraw();
$draw->ellipse(...);
$mask = new Imagick(...);
$mask->drawImage($draw);
$obamaImage->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0);
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: image masking effect.

Post by anthony »

If you just want to make the white areas of the mask white, compose with "Screen"
See Mathematical Masking
http://www.imagemagick.org/Usage/channels/#compose
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Portnoy

Re: image masking effect.

Post by Portnoy »

Is it possible to use screen to mask a binary Group4 tiff image with another binary group4 with the same resolution, dimensions? I am trying to block out portions of a form on a scanned image by creating a tiff with black boxes over the areas I want to expose and using that as a mask over the original image. The synatx I used is

>convert form.tif mask.tif compose -screen output.tif

It does produce the output.tif but all I get is whatever image is listed first. There is no masking of the form image.

Any help would be appreciated.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: image masking effect.

Post by anthony »

You need a -composite operator (or other) to apply the -compose setting! also you forget the '-' for -compose!

Actually your output was probaly a multiple image TIFF with BOTh the original images in it. You should have has errors like "no such file" for "compose" and "screen"!!!

here is what you meant to use...

Code: Select all

convert form.tif mask.tif -compose -screen -composite output.tif
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Portnoy

Re: image masking effect.

Post by Portnoy »

You are correct. I did receive a multipage tiff of the original images. Thank you for the proper command string. After much experimentation I was also able to produce the desired effect by using composite intead of convert so the command line looked like

>composite overlay.tif background.tif -compose screen output.tif

Thanks again.
Post Reply