Php_imagick Ultra-strong PHP image processing extension

Source: Internet
Author: User
Tags imagemagick


Php_imagick is a php extension that can be used by PHP to invoke the ImageMagick feature, and this extension allows PHP to have the same functionality as ImageMagick.
ImageMagick is a powerful, stable and free toolset and development package that can be used to read, write, and process image files in more than 185 basic formats, including popular TIFF, JPEG, GIF, PNG, PDF, and PHOTOCD formats. With ImageMagick, you can dynamically generate images based on the needs of your Web application, and you can resize, rotate, sharpen, subtract, or add effects to a (or a group of) images and save the results of the operation in the same format or other format.

Php_imagick Program Examples
1. Create a thumbnail image and display it

<?php
header(‘Content-type: image/jpeg‘);
$image= newImagick(‘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 thumbnail in a directory and save

<?php
$images= newImagick(glob(‘images/*.JPG‘));
foreach($imagesas$image) {
// Providing 0 forces thumbnailImage to maintain aspect ratio
$image->thumbnailImage(1024,0);
}
$images->writeImages();
?>

3. Animated image of the thumbnail gif

<?php
/* Create a new imagick object and read in GIF */
$im= newImagick("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);

?>

Php_imagick Ultra-strong PHP image processing extension

Related Article

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.