Example analysis of Magickwand usage of PHP image processing class Library

Source: Internet
Author: User
Tags command line imagemagick ini advantage

This article illustrates the Magickwand usage of the PHP image processing class library. Share to everyone for your reference. The specific analysis is as follows:

Magickwand is an extender for PHP that creates an interaction with ImageMagick to process images. It is an excellent alternative to the default GD image function library. In terms of security and ease of use, using Magickwand in PHP is much more secure and quicker than using command line ImageMagick. In addition, Imagick can also be used in PHP as a imagemagick alternative.

There are two forms of Magickwand,

Just establish an interaction with ImageMagick, which must first install ImageMagick, the advantage is that the Extender file is small (general hundreds of k), you can quickly upgrade the ImageMagick version, but the Windows Temp directory requires special permissions.

The Extender itself contains ImageMagick, with the advantage that no additional installation ImageMagick is required, and the temporary directory does not require special permissions, but the Extender file is larger (more than 4M in general).

Magickwand default is not in the PHP installation package, you need to download the PHP Web site, and open this extension in php.ini.

Here is a snippet of code using Magicwand:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 $magick _wand=newmagickwand (); Magickreadimage ($magick _wand, ' rose.jpg '); $drawing _wand=newdrawingwand (); Drawsetfont ($drawing _wand, "/usr/share/fonts/bitstream-vera/vera.ttf"); Drawsetfontsize ($drawing _wand,20); Drawsetgravity ($drawing _wand,mw_centergravity); $pixel _wand=newpixelwand (); Pixelsetcolor ($pixel _wand, "white"); Drawsetfillcolor ($drawing _wand, $pixel _wand); if (Magickannotateimage ($magick _wand, $drawing _wand,0,0,0, "Rose")!= 0) {Magickechoimageblob ($magick _wand);} else {EC Ho magickgetexceptionstring ($magick _wand); }

Installation method:

1. Download Php_magickwand_q16_st.dll for 5.2.x

2. Place it in the extended directory of PHP

3. Total increase in php.ini documents Extension=php_magickwand_q16_st.dll

4. Restart Apache

I hope this article will help you with your PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.