图片网址:data:image/png;base64 (KineticJS)
Posted
技术标签:
【中文标题】图片网址:data:image/png;base64 (KineticJS)【英文标题】:Image URL: data:image/png;base64 (KineticJS) 【发布时间】:2012-12-20 15:33:48 【问题描述】:当使用 KineticJS 到 generate an image of the canvas 时,函数 stage.toDataURL()
给了我一个以 data:image/png;base64
开头的 URL,后跟一个很长的字符串!
问题: URL 是如何工作的?它不包含网络服务器地址,它实际上是从任何地方检索图像吗?
我想将此生成的图像保存到我的网络服务器,将这个非常长的字符串与POST
发送到我的服务器并让服务器curl
这个url 是最佳实践吗?
网址
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkIAAADICAYAAAAEE46XAAALwElEQVR4Xu3ZUW7dVgwE0GRD3f86uqEWBVLARlUIxBXEeZmTb8uPPEMbE/nnD/8IECBAgAABAqUCP0v3tjYBAgQIECBA4Ici5AgIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIEC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BAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgIAi5AYIECBAgACBWgFFqDZ6ixMgQIAAAQKKkBsgQIAAAQIEagUUodroLU6AAAECBAgoQm6AAAECBAgQqBVQhGqjtzgBAgQIECCgCLkBAgQIECBAoFZAEaqN3uIECBAgQICAIuQGCBAgQIAAgVoBRag2eosTIECAAAECipAbIECAAAECBGoFFKHa6C1OgAABAgQIKEJugAABAgQIEKgVUIRqo7c4AQIECBAgoAi5AQIECBAgQKBWQBGqjd7iBAgQIECAgCLkBggQIECAAIFaAUWoNnqLEyBAgAABAoqQGyBAgAABAgRqBRSh2ugtToAAAQIECChCboAAAQIECBCoFVCEaqO3OAECBAgQIKAIuQECBAgQIECgVkARqo3e4gQIECBAgMDfiLaSyZOoJNUAAAAASUVORK5CYII=
【问题讨论】:
【参考方案1】:我认为这是“数据 URI 方案”中的 URL。
http://en.wikipedia.org/wiki/Data_URI_scheme
他们的红点例子很好:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" >
如果你发布数据,base64解码,保存为.png,就是一个有效的png图片。
【讨论】:
以上是关于图片网址:data:image/png;base64 (KineticJS)的主要内容,如果未能解决你的问题,请参考以下文章