图像网址到Base64



是否有任何公共 Web 服务 API 允许提交图像 URL 并返回该图像的 Base64 编码版本?下面是一个示例:http://software.hixie.ch/utilities/cgi/data/data

我想要这个的两个原因:

  1. 我对服务器端了解不多,所以最好避免自己编码。
  2. 使用 HTML5 画布 + 外部网址 + .toDataURL = 安全异常(跨域问题)

没有任何安全考虑,你可以在php中非常简单地做到这一点:

<?php
echo base64_encode(file_get_contents($_GET['url']));

不要害怕"服务器端"。

http://www.greywyvern.com/code/php/binary2base64

http://webcodertools.com/imagetobase64converter

最新更新