Creating transparent Text

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.
Post Reply
monsters

Creating transparent Text

Post by monsters »

Hi,

I want to set the opacity level of some text i'm placing on an image, and I can't figure any way to do it.

Here's the meat of my test harness , which works fine, but only does fully opaque text.

So the question, is what do i need to do to set the text say.. 50% opaque/transparent.. I currently use MagickEvaluateImage to set opacity on images for composite operations, but can't find anything that acts like that on a DrawingWand.

--
$source = NewMagickWand();
$drawing = NewDrawingWand();
$pixel = NewPixelWand();
PixelSetColor($pixel,"#ff0000");
DrawSetFillColor($drawing,$pixel);
DrawSetFont ( $drawing , " Arial " ) ;
DrawSetFontSize( $drawing,$fontsize);
DrawSetFontWeight($drawing,100);
MagickReadImage($source,'3.jpg');

MagickSetFormat($source, 'JPEG');

DrawAnnotation($drawing, $xLocation, $yLocation + $height , "test test");

MagickDrawImage($source, $drawing);

MagickWriteImage($source,'output.jpg');
--
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

After PixelSetColor add a PixelSetOpacity - I think it will look like this:
PixelSetOpacity($pixel,"0.8");
for almost transparent text.

Pete
monsters

Fantastic

Post by monsters »

That does the trick, pixelwand controls all colors and such, check.

If you have an answer for this one,
http://redux.imagemagick.org/discourse- ... php?t=7938

I'll buy you a nice seafood dinner.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

I saw your other post and tried it too. Haven't solved it yet but will probably post what I have.

Seafood? YUMMY :-)

Pete
Post Reply