Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想打开一个图像 url,将其转换为图像,以便我可以使用imagecopymerge()它,然后将其转换为 base64。
imagecopymerge()
我能够使用 来查看图像数据file_get_contents,但我不确定如何将其与imagecreatefromstring、imagecopymerge和结合使用base64_encode。
file_get_contents
imagecreatefromstring
imagecopymerge
base64_encode
The way I finally did it was to use
$img=imagecreatefrompng('url'); ob_start(); imagepng($img); $imgString=ob_get_clean(); $imgBase64=base64_encode($imgString);
I found out that I can't convert an image to a string, and have to use the buffer.