Use php_imagick to resize, rotate, sharpen, reduce color or add special effects to images_PHP Tutorial

WBOY
Release: 2016-07-13 17:18:37
Original
1047 people have browsed it

php_imagick is an expansion package for PHP for image processing. It can complete operations such as changing the size, rotating, sharpening, subtracting colors or adding special effects to images.


1. Install Imagick extension under windows:


1. Download ImageMagick and install

http://image_magick.veidrodis.com/image_magick/binaries/ImageMagick-6.6.2-10-Q16-windows-dll.exe


2. Download php_imagick.dll

http://valokuva.org/outside-blog-content/imagick-windows-builds/php53/imagick-2.3.0-dev/vc9_nts/php_imagick.dll


If you are using thread-safe php, please download

http://valokuva.org/outside-blog-content/imagick- windows-builds/php53/imagick-2.3.0-dev/vc9_zts/php_imagick.dll


3. Settings


Add
in php.ini extension=php_imagick.dll, restart web server


2. Install Imagick extension under Linux:


1.yum install ImageMagick

yum install ImageMagick ImageMagick-devel


2. Test whether the installation is successful


convert -version


3. Install imagick extension


wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz
tar xzvf imagick-3.1.0RC2.tgz
cd imagick-3.1.0RC2
phpize
./configure
make
make install


4. Edit the php.ini file and add the following code at the end of the file


extension=imagick.so


5. Restart apache server


service httpd restart


3. Case


1. Border processing


//by www.tsingyuan.cn
header('Content-type: image/jpeg');
$image = new Imagick('test.jpg');
$color=new ImagickPixel();
$color->setColor("rgb(220,220,220)");
$image->borderImage($color,5,4);
$image->blurImage(5,5,imagick::CHANNEL_GREEN);
echo $image;
Copy after login


2. Generate thumbnails


//by www.tsingyuan.cn
header('Content-type: image/jpeg');
$image = new Imagick('test.jpg');
$image->thumbnailImage(50, 0);
echo $image; 
Copy after login

This article describes how to use php_imagick to change the size, rotate, sharpen, reduce color or add special effects to images. I hope this article can bring inspiration to readers and help them solve their questions. Thank you for reading this article. Welcome to discuss PHP technical issues: 304224365, verification: csl, O(∩_∩)O Thank you!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621635.htmlTechArticlephp_imagick is an expansion package for PHP image processing, which can change the size, rotate, sharpen, and reduce the image. color or add special effects. 1. Install Imagick extension under windows:...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template