private function getColumnFormatFromImage(Imagick $im, $lineHeight)
{
$imgWidth = $im->getimagewidth();
if ($imgWidth == $lineHeight) {
// Return glob of this panel
return array($this->getRasterBlobFromImage($im));
} elseif ($imgWidth > $lineHeight) {
// Calculations
$slicesLeft = ceil($imgWidth / $lineHeight / 2);
$widthLeft = $slicesLeft * $lineHeight;
$widthRight = $imgWidth - $widthLeft;
// Slice up (left)
$left = clone $im;
$left->extentimage($widthLeft, $left->getimageheight(), 0, 0);
// Slice up (right - ensure width is divisible by lineHeight also)
$right = clone $im;
$widthRightRounded = $widthRight < $lineHeight ? $lineHeight : $widthRight;
$right->extentimage($widthRightRounded, $right->getimageheight(), $widthLeft, 0);
// Recurse
$leftBlobs = $this->getColumnFormatFromImage($left, $lineHeight);
$rightBlobs = $this->getColumnFormatFromImage($right, $lineHeight);
return array_merge($leftBlobs, $rightBlobs);
} else {
/* Image is smaller than full width */
$im->extentimage($lineHeight, $im->getimageheight(), 0, 0);
return array($this->getRasterBlobFromImage($im));
}
}