2013-10-30 163 views
0

我想打开一个图像url,将其转换为图像,所以我可以使用imagecopymerge(),然后将其转换为base64。从png创建图像,转换为base64

我能够使用file_get_contents查看图像数据,但我不知道如何将它与imagecreatefromstring,imagecopymergebase64_encode结合使用。

回答

0

的方式我终于做到了是使用

$img=imagecreatefrompng('url'); 
ob_start(); 
imagepng($img); 
$imgString=ob_get_clean(); 
$imgBase64=base64_encode($imgString); 

我发现我不能将图像转换为字符串,并且必须使用缓冲区。