MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
I've added an example of this to my MagickWand Examples in C (see URL in my sig).
The reflection is half the height of the original image (just for added effect) but you can omit that step if you like.
The basic reflection is done by creating a white-black gradient and using that as the opacity of the reflection image.
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
<?php
$mw = NewMagickWand();
MagickReadImage($mw,"strawberry.png");
// we need to get the dimensions of the image
$w = MagickGetImageWidth($mw);
$h = MagickGetImageHeight($mw);
// +matte is the same as -alpha off
MagickSetImageAlphaChannel($mw, MW_DeactivateAlphaChannel);
// clone the input image
$mwr = CloneMagickWand($mw);
// Resize it and flip the image
MagickResizeImage($mwr,$w,$h/2,MW_LanczosFilter,1);
MagickFlipImage($mwr);
// Create the gradient image which will be used as the alpha
// channel in the reflection image
$mwg = NewMagickWand();
MagickSetSize($mwg,$w,$h/2);
MagickReadImage($mwg,"gradient:white-black");
// Copy the gradient in to the alpha channel of the reflection image
MagickCompositeImage($mwr,$mwg,MW_CopyOpacityCompositeOp,0,0);
// Add the reflection image to the wand which holds the original image
MagickAddImage($mw,$mwr);
// Destroy and reuse $mwg as the result image after the appen
if($mwg) $mwg = DestroyMagickWand($mwg);
// Append the reflection to the bottom (MagickTrue) of the original image
$mwg = MagickAppendImages($mw,true);
MagickSetFormat($mwg, "png");
header( 'Content-Type: image/png');
MagickEchoImageBlob($mwg);
?>
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
C API cannot read the format "gradient:white-black"
Which version of ImageMagick are you using? In recent versions of ImageMagick this creates an image containing a gradient from white to black.
your example on your page doesn't link to code by the way?
I'm fixing that up right now. Thanks.
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
I think gradients such as the one in my example were alreadyworking in 6.3.7 so I don't know why it would fail for you. The only thing I can suggest is t oupgrade if you can.
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.