在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:blueimp/JavaScript-Canvas-to-Blob开源软件地址:https://github.com/blueimp/JavaScript-Canvas-to-Blob开源编程语言:JavaScript 91.0%开源软件介绍:JavaScript Canvas to BlobContentsDescriptionCanvas to Blob is a polyfill for Browsers that don't support the standard JavaScript HTMLCanvasElement.toBlob method. It can be used to create Blob objects from an HTML canvas element. SetupInstall via NPM: npm install blueimp-canvas-to-blob This will install the JavaScript files inside
Next include the minified JavaScript Canvas to Blob script in your HTML markup: <script src="js/canvas-to-blob.min.js"></script> Or alternatively, include the non-minified version: <script src="js/canvas-to-blob.js"></script> UsageYou can use the var canvas = document.createElement('canvas')
// Edit the canvas ...
if (canvas.toBlob) {
canvas.toBlob(function (blob) {
// Do something with the blob object,
// e.g. create multipart form data for file uploads:
var formData = new FormData()
formData.append('file', blob, 'image.jpg')
// ...
}, 'image/jpeg')
} RequirementsThe JavaScript Canvas to Blob function has zero dependencies. However, it is a very suitable complement to the JavaScript Load Image function. BrowsersThe following browsers have native support for HTMLCanvasElement.toBlob:
Browsers which implement the following APIs support This includes the following browsers:
APIIn addition to the // Uncomment the following line when using a module loader like webpack:
// var dataURLtoBlob = require('blueimp-canvas-to-blob')
// black+white 3x2 GIF, base64 data:
var b64 = 'R0lGODdhAwACAPEAAAAAAP///yZFySZFySH5BAEAAAIALAAAAAADAAIAAAIDRAJZADs='
var url = 'data:image/gif;base64,' + b64
var blob = dataURLtoBlob(url) TestLicenseThe JavaScript Canvas to Blob script is released under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论