DJ Mike's Tutorials: PHP

ImageMagick Functions

^

Imagick::compositeImage

Description:
bool Imagick::compositeImage ( Imagick $composite_object , int $composite , int $x , int $y [, int $channel = Imagick::CHANNEL_ALL ] )

Composite one image onto another

Parameters:
composite_object
Imagick object which holds the composite image
compose
Composite operator. Values:
imagick::COMPOSITE_DEFAULT
The default composite operator
imagick::COMPOSITE_UNDEFINED
Undefined composite operator
imagick::COMPOSITE_NO
No composite operator defined
imagick::COMPOSITE_ADD
The result of image + image
imagick::COMPOSITE_ATOP
The result is the same shape as image, with composite image obscuring image where the image shapes overlap
imagick::COMPOSITE_BLEND
Blends the image
imagick::COMPOSITE_BUMPMAP
The same as COMPOSITE_MULTIPLY, except the source is converted to grayscale first.
imagick::COMPOSITE_CLEAR
Makes the target image transparent
imagick::COMPOSITE_COLORBURN
Darkens the destination image to reflect the source image.
imagick::COMPOSITE_COLORDODGE
Brightens the destination image to reflect the source image
imagick::COMPOSITE_COLORIZE
Colorizes the target image using the composite image.
imagick::COMPOSITE_COPYBLACK
Copies black from the source to target.
imagick::COMPOSITE_COPYBLUE
Copies blue from the source to target.
imagick::COMPOSITE_COPY
Copies the source image on the target image.
imagick::COMPOSITE_COPYCYAN
Copies cyan from the source to target.
imagick::COMPOSITE_COPYGREEN
Copies green from the source to target.
imagick::COMPOSITE_COPYMAGENTA
Copies magenta from the source to target.
imagick::COMPOSITE_COPYOPACITY
Copies opacity from the source to target.
imagick::COMPOSITE_COPYRED
Copies red from the source to target.
imagick::COMPOSITE_COPYYELLOW
Copies yellow from the source to target.
imagick::COMPOSITE_DARKEN
Darkens the target image.
imagick::COMPOSITE_DSTATOP
The part of the destination lying inside of the source is composited over the source and replaces the destination.
imagick::COMPOSITE_DST
The target is left untouched.
imagick::COMPOSITE_DSTIN
The parts inside the source replace the target.
imagick::COMPOSITE_DSTOUT
The parts outside the source replace the target.
imagick::COMPOSITE_DSTOVER
Target replaces the source.
imagick::COMPOSITE_DIFFERENCE
Subtracts the darker of the two constituent colors from the lighter.
imagick::COMPOSITE_DISPLACE
Shifts target image pixels as defined by the source
imagick::COMPOSITE_DISSOLVE
Dissolves the source in to the target.
imagick::COMPOSITE_EXCLUSION
Produces an effect similar to that of imagick::COMPOSITE_DIFFERENCE, but appears as lower contrast.
imagick::COMPOSITE_HARDLIGHT
Multiplies or screens the colors, dependent on the source color value imagick::COMPOSITE_HUE
Multiplies or screens the colors, dependent on the source color value imagick::COMPOSITE_HUE
Modifies the hue of the target as defined by source
imagick::COMPOSITE_IN
Composites source into the target
imagick::COMPOSITE_LIGHTEN
Lightens the target as defined by source.
imagick::COMPOSITE_LUMINIZE
Luminizes the target as defined by source.
imagick::COMPOSITE_MINUS
Substracts the source from the target.
imagick::COMPOSITE_MODULATE
Modulates the target brightness, saturation and hue as defined by source
imagick::COMPOSITE_MULTIPLY
Multiplies the target to the source.
imagick::COMPOSITE_OUT
Composites outer parts of the source on the target.
imagick::COMPOSITE_OVER
Composites source over the target.
imagick::COMPOSITE_OVERLAY
Overlays the source on the target
imagick::COMPOSITE_PLUS
Adds the source to the target.
imagick::COMPOSITE_REPLACE
Replaces the target with the source.
imagick::COMPOSITE_SATURATE
Saturates the target as defined by the source.
imagick::COMPOSITE_SCREEN.
The source and destination are complemented and then multiplied and then replace the destination
imagick::COMPOSITE_SOFTLIGHT
Darkens or lightens the colors, dependent on the source.
imagick::COMPOSITE_SRCATOP
The part of the source lying inside of the destination is composited onto the destination.
imagick::COMPOSITE_SRC
The source is copied to the destination.
imagick::COMPOSITE_SRCIN
The part of the source lying inside of the destination replaces the destination.
imagick::COMPOSITE_SRCOUT
The part of the source lying outside of the destination replaces the destination.
imagick::COMPOSITE_SRCOVER
The source replaces the destination
imagick::COMPOSITE_SUBTRACT
Subtract the colors in the source image from the destination image.
imagick::COMPOSITE_THRESHOLD
The source is composited on the target as defined by source threshold.
imagick::COMPOSITE_XOR
The part of the source that lies outside of the destination is combined with the part of the destination that lies outside of the source
x
The column offset of the composited image
y
The row offset of the composited image
channel
Provide any channel constant that is valid for your channel mode. To apply to more than one channel, combine channeltype constants using bitwise operators. Refer to this list of channel constants.
Return Values
Returns TRUE on success.

Example

+ =
Text
<?php
# URL's from the web
$board_url "http://eclecticdjs.com/mike/tutorials/php/imagemagick/examples_09/board.png";
$printer_url "http://eclecticdjs.com/mike/tutorials/php/imagemagick/examples_09/printer.png";

# read files
$board_blob file_get_contents("$board_url");
$printer_blob file_get_contents("$printer_url");

# create new image objects
$board = new imagick();
$printer = new imagick();

# read blobs
$board->readImageBlob("$board_blob");
$printer->readImageBlob("$printer_blob");

# composite
$board->compositeImage($printerimagick::COMPOSITE_ATOP00);

# write composited image
$board->writeImage ("composite.png" );

# you can also send image to the browser
header("Content-type: image/png");
echo 
$board;
?>


^


Was this webpage useful to you? You can support this website by donating.


Created by DJ Mike from Santa Barbara

DJ Mike


<a href="http://www.statcounter.com/" target="_blank"> <img src="http://c5.statcounter.com/counter.php?sc_project=1321035&java=0&security=da2193dc" alt="counter free hit invisible" border="0" /></a>