protected function getCenterOffset(\Imagick $image, $targetWidth, $targetHeight)
    {
        $size = $image->getImageGeometry();
        $originalWidth = $size['width'];
        $originalHeight = $size['height'];
        $goalX = (int) (($originalWidth-$targetWidth)/2);
        $goalY = (int) (($originalHeight-$targetHeight)/2);

        return array('x' => $goalX, 'y' => $goalY);
    }