Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Base64编码错误_Php_Imagemagick - Fatal编程技术网

Php Base64编码错误

Php Base64编码错误,php,imagemagick,Php,Imagemagick,单击上载按钮时图像未显示,base64编码错误 浏览器只是显示二进制代码。 $showimage = "images/".$_FILES['image']["name"]; $show = new imagick( $showimage ); $points = array( 0,0, 0,0, # top left 213,0, 213,20, # top right 213,160, 213,110, # bot

单击上载按钮时图像未显示,base64编码错误

浏览器只是显示二进制代码。
 $showimage = "images/".$_FILES['image']["name"];

$show = new imagick( $showimage );
$points = array(
            0,0, 0,0, # top left  
            213,0, 213,20, # top right
            213,160, 213,110, # bottom right 
            0,160,  0,160,# bottum left
            );
$show->setimagebackgroundcolor("#ffffff");
$show->setImageVirtualPixelMethod( imagick::VIRTUALPIXELMETHOD_BACKGROUND );
$show->distortImage( Imagick::DISTORTION_PERSPECTIVE, $points, TRUE );
echo "<img src='$show'>";

?>
$showimage=“images/”$\u文件['image'][“name”];
$show=new imagick($showimage);
$points=数组(
0,0,0,#左上角
213,0,213,20#右上角
21316213110#右下角
01600160,#左下角
);
$show->setimagebackgroundcolor(#ffffff”);
$show->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD\u背景);
$show->transformmage(Imagick::transformation\u PERSPECTIVE,$points,TRUE);
回声“;
?>

您需要为图像类型提供
标题
,也不必使用
标记进行
回送

请按照下面的代码操作

$showimage = "images/".$_FILES['image']["name"];

$show = new imagick( $showimage );
$points = array(
            0,0, 0,0, # top left  
            213,0, 213,20, # top right
            213,160, 213,110, # bottom right 
            0,160,  0,160,# bottum left
            );
$show->setimagebackgroundcolor("#ffffff");
$show->setImageVirtualPixelMethod( imagick::VIRTUALPIXELMETHOD_BACKGROUND );
$show->distortImage( Imagick::DISTORTION_PERSPECTIVE, $points, TRUE );
header("Content-Type: image/png"); //<--- Provide the header
echo $show; //<--- Removed the tags

?>
$showimage=“images/”$\u文件['image'][“name”];
$show=new imagick($showimage);
$points=数组(
0,0,0,#左上角
213,0,213,20#右上角
21316213110#右下角
01600160,#左下角
);
$show->setimagebackgroundcolor(#ffffff”);
$show->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD\u背景);
$show->transformmage(Imagick::transformation\u PERSPECTIVE,$points,TRUE);
标题(“内容类型:图像/png”)// $imgData=addslashes(文件获取内容($\u文件['userImage']['tmp\u名称]])

//将图像存储到包含ytpe blo bin mysql数据的$imgData

     echo '<img src="data:image/png;base64,' . base64_encode($imgData) . '"/>';
echo';
试试:

$imageData=base64\u编码($show->getImageBlob);
回声“;
$imageData = base64_encode($show->getImageBlob);
echo "<img src='data:image/png;base64,$imageData'>";