当前位置:网站首页>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 |
|
边栏推荐
- bashrc与profile
- Leetcode - Sword finger offer 05 Replace spaces
- Pert diagram (engineering network diagram)
- Hangdian oj2092 integer solution
- Substance Painter筆記:多顯示器且多分辨率顯示器時的設置
- Bashrc and profile
- Hangdian oj2054 a = = B? ???
- Beginner JSP
- Applet directory structure
- WPF DataGrid realizes the UI interface to respond to a data change in a single line
猜你喜欢

【历史上的今天】7 月 7 日:C# 发布;Chrome OS 问世;《仙剑奇侠传》发行

Vscode configuration uses pylint syntax checker

Parsing of XML files

设备故障预测机床故障提前预警机械设备振动监测机床故障预警CNC震动无线监控设备异常提前预警

CVPR2022 | 医学图像分析中基于频率注入的后门攻击

今日睡眠质量记录78分

AutoCAD - how to input angle dimensions and CAD diameter symbols greater than 180 degrees?

OAuth 2.0 + JWT protect API security

Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?

云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
随机推荐
MRS离线数据分析:通过Flink作业处理OBS数据
Regular expression integer positive integer some basic expressions
PLC:自动纠正数据集噪声,来洗洗数据集吧 | ICLR 2021 Spotlight
数据湖(九):Iceberg特点详述和数据类型
NLLB-200:Meta开源新模型,可互译200种语言
杭电oj2092 整数解
C # use TCP protocol to establish connection
ndk初学习(一)
PD虚拟机教程:如何在ParallelsDesktop虚拟机中设置可使用的快捷键?
ES日志报错赏析-trying to create too many buckets
VSCode 配置使用 PyLint 语法检查器
Leetcode——344. Reverse string /541 Invert string ii/151 Reverse the word / Sword finger in the string offer 58 - ii Rotate string left
Demis Hassabis谈AlphaFold未来目标
UML 顺序图(时序图)
electron remote 报错
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
Bashrc and profile
LeetCode每日一题(636. Exclusive Time of Functions)
Is the spare money in your hand better to fry stocks or buy financial products?
LeetCode 648. Word replacement