图片转base64 PHP代码:
$content = file_get_content('img.jpg');
echo base64_encode($content);
图片转base64 Python代码:
import base64
def image_to_base64(image_path):
with open(image_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return encoded_string.decode('utf-8')
image_path = "img.jpg" # 替换为你的图片路径
base64_str = image_to_base64(image_path)
print(base64_str)
在线图片转base64:https://tool.jisuapi.com/pic2base64.html


© 2015-2025 杭州极速互联科技有限公司 版权所有 浙ICP备17047587号-4 浙公网安备33010502005096 增值电信业务经营许可证:浙B2-20190875