It seems that this method can return a zero-length string if faced with large-ish data. No exceptions are thrown.
<?php
$image = new Imagick();
if (!$image->newImage(1000,1,'white')) throw new Exception();
if (!$image->scaleImage(0,200)) throw new Exception();
print "Image size: {$image->getImageWidth()},{$image->getImageHeight()}\n";
if (!$image->setImageFormat("jpeg")) throw new Exception();
$a = $image->getImageBlob();
print "Rendered to ".strlen($a)." bytes\n";
?>
Restrict your output image size, or ensure that the blob you get back isn't empty. (Note that IM seems to be doing the work, it delays for some time. But there's no indication of any error anywhere.)
Imagick::getImageBlob
(PECL imagick 2.0.0)
Imagick::getImageBlob — 画像シーケンスを blob で返す
説明
string Imagick::getImageBlob
( void
)
画像フォーマットを直接記憶します。 これは、画像シーケンスを文字列で返します。 画像のフォーマットによって、返される blob の形式 (GIF, JPEG, PNG, など) が決まります。 別の画像フォーマットを返すには Imagick::SetImageFormat() を使用します。
返り値
画像を含む文字列を返します。
エラー / 例外
エラー時に ImagickException をスローします。
Trevor ¶
1 year ago
