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SRxwZEt53tKFEmNXELDRMe1OIHHYRqvsYcJbtkzi6w4CJp3L57zlH97uwEiWEALGCMy32vV4KoExmiSgtwjMAqnHUwl6630y3BoCwatdj6cSWEOSBPUagSCQejyVoNfeJ+OtISAbG8oPpzebhmDNEBJECDSJgAykJnWgsgmB1iNAgdR6F5IBLiBAgeSCF0iH1iNAgdR6F5IBLiBAgeSCF0iH1iMgA+lvBpaY8KrFmshpI2/ztg9YedxMeFXLTeSY8FrWIQikbf4QVhLdUmVrpZEHeW0cTenQVLkqZg3psDocPmQDXtzvwOPzqjaUTHdFBx6x/11xHdZq+13uYokcptQtsptsi38R4bdx0ZQOTZWrYtaQDp7nXT+dgN9zF4rke0sL7OZwOLTu97brEA0k1ak4bGjKbkDWtfPsXZjo8BiW6R2rZJWmm9KhqXJVMBvSASe58ePjG0zwwO9c7Irl5cdrvD6/t1GH/wOb3Y6HxLNlqgAAAABJRU5ErkJggg==
图片转base64方法
getBase64(imgUrl, callback) {
let image = new Image();
// 解决跨域问题
image.setAttribute("crossOrigin", "anonymous");
let imageUrl = imgUrl;
image.src = imageUrl;
// image.onload为异步加载
image.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext("2d");
// eslint-disable-next-line no-undef
context.drawImage(image, 0, 0, image.width, image.height);
var quality = 0.8;
// 这里的dataurl就是base64类型
// 使用toDataUrl将图片转换成jpeg的格式,不要把图片压缩成png,因为压缩成png后 base64的字符串可能比不转换前的长!
let dataurl = canvas.toDataURL("image/jpeg", quality);
callback ? callback(dataurl) : null; //调用回调函数
};
}
使用:
this.getBase64('./test.img', dataURL => {
console.log(dataURL );
})
你的图片是用户选取的嘛
试试这样
const fileInput = document.getElementById("fileInput");
const reader = new FileReader();
fileInput.onchange = (e) => {
reader.readAsDataURL(e.target.files[0]);
}
reader.onload = (e) => {
console.log(e.target.result);
}
这种格式叫datauri
它的格式非常简单: data:[<mediatype>][;base64],<data>
了解它的格式之后你可以非常轻松的自己实现。例: https://stackoverflow.com/questions/7845892/create-data-uris-on-the-fly
// 把本地图片文件路径转换为 Base64 编码字符串
async function imageToBase64(imagePath) {
const response = await fetch(imagePath);
const blob = await response.blob();
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}
imageToBase64('/aaaaa/static/img/zhexian.41eafbf5.png')
.then((base64) => {
console.log(base64); // 输出 Base64 编码字符串
})
.catch((error) => {
console.error('Error converting image to base64:', error);
});
创建一个img元素,监听img的onload事件,在onload事件中把图片渲染到canvas中,使用canvas转base64
可以参考:https://blog.csdn.net/wgh4318/article/details/126222541
问题内容: 我有使用地址的应用程序(它存储它们的时间很长),因此它只了解地址。 可以将地址转换为with 吗? 问题答案: 尽管IPv4地址范围具有等效的IPv6,但是您不能将所有IPv6地址都转换为IPv4-IPv6地址比IPv4地址更多。 解决此问题的唯一明智的方法是更新您的应用程序,以便能够理解和存储IPv6地址。
所以有几个网站会为你计算你的链接本地ipv6地址,就像这里的这个。 尽管如此,它并没有给出任何有用的关于这个地址是如何计算的,也没有输入参数是什么。那么,如果一个人知道自己的ipv4地址、子网掩码和网关地址,计算链路本地ipv6地址的过程(或算法)是什么?我正在使用SCTP套接字做一个项目,该项目使用ISATAP网络隧道和LL ipv6地址用于构建ISATAP地址。
页面代码中引用本地图片: 页面中的地址: 我想将 /src/assets/image/login/icon_login.png 变成 http://localhost:3000/src/assets/image/login/icon_login.png 应该如何配置? 我配置了vite里的base 没有效果
我在服务器上执行如下命令: netstat -anp | grep 6379 查看redis的6379端口情况,结果如下所示: 上面的192.168.0.11是内网地址,41.92.250.40是公网地址(当然为了安全我这边是随便改了不是真实的地址) 阿某云买的服务器,上面有两个ip 41.92.250.40(公) 192.168.0.11(私有) 现在我对Local Address 本地地址还有
X2.2.0新增 sp_get_image_url($file,$style='') 功能: 转化数据库保存图片的文件路径,为可以访问的url 参数: $file: 数据库中保存的文件名 $style:样式(七牛) 返回: 类型string,图片可以访问的url 使用: $url = sp_get_image_url('portal/23232.png');
X2.2.0新增 sp_get_image_preview_url($file,$style='watermark') 功能: 获取图片预览链接 参数: $file: 数据库中保存的文件名 $style:样式(七牛) 返回: 类型string,图片预览链接 使用: $url = sp_get_image_preview_url('portal/23232.png');