当前位置:网站首页>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 |
|
边栏推荐
- Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
- MLGO:Google AI发布工业级编译器优化机器学习框架
- 【立体匹配论文阅读】【三】INTS
- Data connection mode in low code platform (Part 2)
- 2022PAGC 金帆奖 | 融云荣膺「年度杰出产品技术服务商」
- c#通过frame 和 page 切换页面
- PAG体验:十分钟完成AE动效部署上线各平台!
- Internal sort - insert sort
- Similarities and differences between switches and routers
- Leetcode——剑指 Offer 05. 替换空格
猜你喜欢
Hands on Teaching: XML modeling
潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
Data flow diagram, data dictionary
PyTorch模型训练实战技巧,突破速度瓶颈
通过 iValueConverter 给datagrid 的背景颜色 动态赋值
GAN发明者Ian Goodfellow正式加入DeepMind,任Research Scientist
Reverse non return to zero code, Manchester code and differential Manchester code of common digital signal coding
OAuth 2.0 + JWT 保护API安全
Selenium Library
随机推荐
Csma/cd carrier monitoring multipoint access / collision detection protocol
First choice for stock account opening, lowest Commission for stock trading account opening, is online account opening safe
多商戶商城系統功能拆解01講-產品架構
Seven propagation behaviors of transactions
Excuse me, as shown in the figure, the python cloud function prompt uses the pymysql module. What's the matter?
OAuth 2.0 + JWT 保护API安全
Search engine interface
LeetCode每日一题(636. Exclusive Time of Functions)
leetcode:648. 单词替换【字典树板子 + 寻找若干前缀中的最短符合前缀】
Mlgo: Google AI releases industrial compiler optimized machine learning framework
The longest ascending subsequence model acwing 1012 Sister cities
内部排序——插入排序
半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!
NLLB-200:Meta开源新模型,可互译200种语言
Wired network IP address of VMware shared host
找到自己的价值
杭电oj2054 A == B ? ???
The longest ascending subsequence model acwing 1014 Mountaineering
股票开户首选,炒股交易开户佣金最低网上开户安全吗
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