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
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); |
2. Create a thumbnail in a directory and save
$images = new Imagick( glob ( ‘images/*.JPG‘ )); |
foreach ( $images as $image ) { |
// Providing 0 forces thumbnailImage to maintain aspect ratio |
$image ->thumbnailImage(1024,0); |
3. Animated image of the thumbnail gif
/* Create a new imagick object and read in GIF */ |
$im = new Imagick( "example.gif" ); |
$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