Home >Backend Development >PHP Tutorial >PHP image processing module magickwand_PHP tutorial
MagickWand is a PHP module used to access ImageMagick's image processing library. Here is a code snippet using MagicWand:
<ol class="dp-c"><li class="alt"><span><span><?php </span></span></li><li><span> </span><span class="vars">$magick_wand</span><span>=NewMagickWand(); </span></li><li class="alt"><span> MagickReadImage(</span><span class="vars">$magick_wand</span><span>,</span><span class="string">rose.jpg</span><span>); </span></li><li><span> </span><span class="vars">$drawing_wand</span><span>=NewDrawingWand(); </span></li><li class="alt"><span> DrawSetFont(</span><span class="vars">$drawing_wand</span><span>,</span><span class="string">"/usr/share/fonts/bitstream-vera/Vera.ttf"</span><span>); </span></li><li><span> DrawSetFontSize(</span><span class="vars">$drawing_wand</span><span>,20); </span></li><li class="alt"><span> DrawSetGravity(</span><span class="vars">$drawing_wand</span><span>,MW_CenterGravity); </span></li><li><span> </span><span class="vars">$pixel_wand</span><span>=NewPixelWand(); </span></li><li class="alt"><span> PixelSetColor(</span><span class="vars">$pixel_wand</span><span>,</span><span class="string">"white"</span><span>); </span></li><li><span> DrawSetFillColor(</span><span class="vars">$drawing_wand</span><span>,</span><span class="vars">$pixel_wand</span><span>); </span></li><li class="alt"><span> </span><span class="keyword">if</span><span> (MagickAnnotateImage(</span><span class="vars">$magick_wand</span><span>,</span><span class="vars">$drawing_wand</span><span>,0,0,0,</span><span class="string">"Rose"</span><span>) != 0) </span></li><li><span> { </span></li><li class="alt"><span> MagickEchoImageBlob( </span><span class="vars">$magick_wand</span><span> ); </span></li><li><span> } </span></li><li class="alt"><span> </span><span class="keyword">else</span><span> </span></li><li><span> { </span></li><li class="alt"><span> </span><span class="func">echo</span><span> MagickGetExceptionString(</span><span class="vars">$magick_wand</span><span>); </span></li><li><span> } </span></li><li class="alt"><span>?> </span></span></li></ol>
Installation method:
Download php_magickwand_q16_st.dll for 5.2.x
Place it in the PHP extension directory
Add extension=php_magickwand_q16_st.dll
to the php.ini fileRestart apache