我正在使用b64-to-blob和下面的函数将base64图像转换为blob并将它们注入到html中。除了Safari 11之外,我测试的所有浏览器都能正常工作。我似乎无法在Google上找到任何解决方案。
HTML文件是独立的,需要在没有服务器的情况下在本地工作。
任何帮助,将不胜感激。
b64-to-blob功能:
(function(root, globalName, factory) {
if (typeof define === 'function' && define.amd) {
// AMD:
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node:
module.exports = factory();
// Use module export as simulated ES6 default export:
module.exports.default = module.exports;
} else {
// Browser:
window[globalName] = factory();
}
}(this, 'b64toBlob', function() {
'use strict';
return function b64toBlob(b64Data, contentType, sliceSize) {
contentType = contentType || '';
sliceSize = sliceSize || 512;
var byteCharacters = atob(b64Data);
var byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {type: contentType});
return blob;
};
}));
钩住功能:
$(document).ready(function() {
var contentTypePng = 'image/png';
var favicon =
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAF0mx+sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXg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S4UWdwZJjBhHjILoNZ+Hpe8XFTi9D6PNi1jHQptr/djEXi4zOHLHGc6knYzo4vstN909gyPpWN57KsnnD5Hx7dv6am8v4U+UWd66WnBOJZdHrSEQvSzgd1VToK8ezxNyfFzx4ZxMHTuvf2agAOm7Ouc9KJKCXLbLw8MvL6EddOUju6Dv7P6IS7jp2TnaQiXr04OURD8gOjklkEVKDURm/YAp/0RhbM0dY5AW6IEAAAA==';
var faviconBlob = b64toBlob(favicon, contentTypePng);
var faviconBlobUrl = URL.createObjectURL(faviconBlob);
var imageOneBlob = b64toBlob(imageSrcOne, contentTypeJpg);
var imageOneBlobUrl = URL.createObjectURL(imageOneBlob);
var blob1 = faviconBlobUrl;
var blob2 = imageOneBlobUrl;
// document.querySelector('#favicon').href = blob1;
// document.querySelector('#imageOne').src = blob2;
$('#favicon').attr('href', blob1);
$('#imageOne').attr('src', blob2);
});
浏览器中的示例输出(本地查看index.html):
<img id="imageOne" src="blob:null/6cab2520-7a96-4cd4-b94d-d1cf3d58baae" alt="">
我废弃了blob并采用了不同的方法进行Base64图像转换,现在可以在所有浏览器中使用。
参考:
http://dataurl.net/#dataurlmaker