当前位置:网站首页>JS image to Base64
JS image to Base64
2022-07-07 14:28:00 【Snail games】
This article mainly introduces js Picture turn base64 The way , Now share with you , Also give you a reference .
Mode one :Blob and FileReader object
Realization principle :
Use xhr Ask for pictures , And set the returned file type as Blob object [xhr.responseType = "blob"]
Use FileReader Object reception blob
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
Mode two :canvas.toDataURL() Method
Realization principle :
Use canvas.toDataURL() Method
Need to solve the cross domain problem of pictures image.crossOrigin = '';
Used Jquery Library $.Deferred() Method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
边栏推荐
- 多商戶商城系統功能拆解01講-產品架構
- c#利用 TCP 协议建立连接
- MRS离线数据分析:通过Flink作业处理OBS数据
- Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
- js 获取当前时间 年月日,uniapp定位 小程序打开地图选择地点
- [untitled]
- OAuth 2.0 + JWT 保护API安全
- Introduction to sakt method
- 关于后台动态模板添加内容的总结 Builder使用
- Leetcode——236. The nearest common ancestor of binary tree
猜你喜欢
随机推荐
潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)
SAKT方法部分介绍
oracle 触发器实现级联更新
Oracle Linux 9.0 officially released
Nllb-200: meta open source new model, which can translate 200 languages
AutoCAD - how to input angle dimensions and CAD diameter symbols greater than 180 degrees?
Codes de non - retour à zéro inversés, codes Manchester et codes Manchester différentiels couramment utilisés pour le codage des signaux numériques
Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
IP address home location query full version
Leetcode——344. Reverse string /541 Invert string ii/151 Reverse the word / Sword finger in the string offer 58 - ii Rotate string left
The longest ascending subsequence model acwing 482 Chorus formation
NDK beginner's study (1)
6、Electron无边框窗口和透明窗口 锁定模式 设置窗口图标
PAG体验:十分钟完成AE动效部署上线各平台!
LeetCode 648. 单词替换
NLLB-200:Meta开源新模型,可互译200种语言
LeetCode每日一题(636. Exclusive Time of Functions)
ES日志报错赏析-maximum shards open
Data connection mode in low code platform (Part 2)
Applet directory structure









