本文主要是介绍php将图片链接直接转化为base64编码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/** 把网络图片图片转成base64
* @param string $img 图片地址
* @return string
*/
/网络图片转为base64编码/
protected function imgtobase64($img='', $imgHtmlCode=true)
{$imageInfo = getimagesize($img);$base64 = "" . chunk_split(base64_encode(file_get_contents($img)));return 'data:' . $imageInfo['mime'] . ';base64,' . chunk_split(base64_encode(file_get_contents($img)));
}
这篇关于php将图片链接直接转化为base64编码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!