squar
<?php
/* Define width and height of the thumbnail */
$width = 100;
$height = 100;
/* Instanciate and read the image in */
$im = new Imagick( "image.jpg" );
/* Fit the image into $width x $height box
The third parameter fits the image into a "bounding box" */
$im->thumbnailImage( $width, $height, true );
/* The overlay x and y coordinates */
$max = max($im->getImageWidth(), $im->getImageHeight());
$w = $max - $im->getImageWidth();
$h = $max - $im->getImageHeight();
$pad_x = empty($w) ? 0 : $w/2;
$pad_y = empty($h) ? 0 : $h/2;
$im->borderImage('pink', $pad_x, $pad_y);
/* Output the image*/
header( "Content-Type: image/png" );
echo $im;