Using Imagick with PHP

Have you ever used the PHP class to play with image. You can use imagick to crop, create thumbnail and many more. For details see example and visit @ http://php.net/manual/en/book.imagick.php
<?php
/* Create new object */
$im = new Imagick();
clone();
$fit = $im->clone();
$fixed = $im->clone();
$crop = $im->clone();

/* Create a normal thumbnail 100x width, save dimensions */
$normal->thumbnailImage( 100, null );
$normal->writeImage( "normal_thumbnail.jpg" );

/* Create a fit thumbnail, both sides need to be smaller
than the given values, save dimensions */
$fit->thumbnailImage( 100, 100, true );
$fit->writeImage( "fit_thumbnail.jpg" );

/* Create a fixed size thumbnail, ignore dimensions */
$fixed->thumbnailImage( 100, 100 );
$fixed->writeImage( "fixed_thumbnail.jpg" );

/* Create a thumbnail, keep dimensions, crop overflowing parts */
$crop->cropThumbnailImage( 100, 100 );
$crop->writeImage( "crop_thumbnail.jpg" );

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s