此图像格式没有解码委托-Imagick-php

此图像格式没有解码委托-Imagick-php,php,image,imagick,resize-image,Php,Image,Imagick,Resize Image,这是我的Imagick函数,我正在尝试使用base64编码数据编写图像。它的投掷错误 “此图像格式无解码委托”根据手册,Imagick::readImageBlob需要一个二进制字符串,而您需要为其提供base64编码字符串。首先使用函数base64\u Decode对字符串进行解码,并将结果提供给readImageBlob $path=getcwd(); $rawstring = $_POST['img_data']; $malestr = str_replace("data:ima

这是我的Imagick函数,我正在尝试使用base64编码数据编写图像。它的投掷错误


“此图像格式无解码委托”

根据手册,
Imagick::readImageBlob
需要一个二进制字符串,而您需要为其提供base64编码字符串。首先使用函数
base64\u Decode
对字符串进行解码,并将结果提供给
readImageBlob

$path=getcwd();
$rawstring = $_POST['img_data'];    
$malestr = str_replace("data:image/jpeg;base64,", "", $rawstring);
$img = new Imagick();
$img->readImageBlob($malestr);
$img->writeImage($path."/media/import/new.jpg");  

readImageBlob
获取二进制字符串。首先,解码
$malestr
的内容-使用函数
base64\u decode
谢谢Cherry,也请检查这个问题。和一个pbm站在一起。看这里,检查原始$malestr(解码前)没有空格,其中+应该是Cherry,这是我新问题的答案吗???我不知道,在解码前检查字符串的内容-不应该有空格。请检查这个问题@Cherry
// your code above
$malestr = str_replace("data:image/jpeg;base64,", "", $rawstring);

$malestr = base64_decode($malestr);
if (!$malestr) die('Unable to decode the string');

$img = new Imagick();
$img->readImageBlob($malestr);