private function getRasterBlobFromImage(Imagick $im)
{
$blob = $im->getimageblob();
/* Find where header ends */
$i = strpos($blob, "P4\n") + 2;
while ($blob[$i + 1] == '#') {
$i = strpos($blob, "\n", $i + 1);
}
$i = strpos($blob, "\n", $i + 1);
/* Return raster data only */
$subBlob = substr($blob, $i + 1);
return $subBlob;
}