php_imagick powerful PHP image processing extension

Php_imagick is a PHP extension can call ImageMagick for PHP functions, PHP can make use of this extension have the same functionality and ImageMagick. ImageMagick is a powerful, stable and free set of tools and development kits can be used to read, write and process more than 185 kinds of basic image file formats, including the popular TIFF, JPEG, GIF, PNG, PDF, and other formats PhotoCD . The results using the ImageMagick, you can dynamically generate web applications needed images can also be changed to a size (or a group), rotate, sharpen, special effects or to increase the subtractive color operation, and operated in the same format or saved in other formats. php_imagick Program Example 1. Create a thumbnail and displayed
<?php
header('Content-type: image/jpeg');
$image = new Imagick('image.jpg');
// If 0 is provided as a width or height parameter,// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>
2. Create a directory under the thumbnails, and save
<?php
$images = new Imagick(glob('images/*.JPG'));
foreach($images as $image) {
// Providing 0 forces thumbnailImage to maintain aspect ratio
$image->thumbnailImage(1024,0);
}
$images->writeImages();
?>
3. thumbnail animated GIF images
<?php
/* Create a new imagick object and read in GIF */
$im = new Imagick("example.gif");
/* Resize all frames */
foreach ($im as $frame) {
/* 50x50 frames */
$frame->thumbnailImage(50, 50);
/* Set the virtual canvas to correct size */
$frame->setImagePage(50, 50, 0, 0);
}/* Notice writeImages instead of writeImage */
$im->writeImages("example_small.gif", true);
?>

Reproduced in: https: //my.oschina.net/766/blog/211296

Guess you like

Origin blog.csdn.net/weixin_33910460/article/details/91546928