图像包含错误与 imagick


The image contain error with imagick

<?php
header('Content-type: image/jpeg');
$image = new Imagick('image.jpg');
// If 0 is provided as a width or height parameter,
// aspect ratio is maintained
$image->thumbnailImage(100, 0);
echo $image;
?>

给出错误 无法显示图像"http://localhost/test/into.php",因为它包含错误。请解决这个问题?

请在注释行中阅读详细信息

<?php
//drawing stuff that creates $image
ob_get_clean(); //this statement is what mine was lacking before I could get it to work properly
header("Content-type: image/png");
echo $image;

您的图像是在 0 像素高度创建的,格式可能无效。尝试查看文档。

$image->thumbnailImage(100, 100);