Home >php教程 >php手册 >PHP图像处理模块 magickwand

PHP图像处理模块 magickwand

WBOY
WBOYOriginal
2016-06-13 10:38:22814browse

  MagickWand 是一个PHP的模块,用来访问 ImageMagick 的图像处理库。下面是一个使用 MagicWand 的代码片段:

 

<ol class="dp-c">
<li class="alt"><span><span><?php  </span></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></li>
</ol>

安装方法:

  下载 php_magickwand_q16_st.dll for 5.2.x

  将其放在PHP的扩展目录

  在php.ini文件总增加 extension=php_magickwand_q16_st.dll

  重新启动apache

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn