如何解决Javascript客户端读取位readInt16LE小端
使用Cloudflare工作者,我需要将此代码(读取无扩展的Lossy WebP)从NodeJS转换为javascript客户端:
const atob = async (str) => Buffer.from(str,'base64');
const binaryBuffer = await atob(v);
const buffer = binaryBuffer.slice(20,30);
// End Signature byte should not be encountered
if (buffer[0] === 0x2f) {
console.log('bad');
}
// Extract properties
const height = buffer.readInt16LE(8) & 0x3fff;
const width = buffer.readInt16LE(6) & 0x3fff;
// width and height should be <= 16384 (Avoid compression bomb)
if (width > 16384 || height > 16384) {
console.log('super bad');
}
客户端上不存在缓冲区,但是还可以,因为atob存在。
readInt16LE在客户端上不存在,并且我没有解决方案:/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。