Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解析tiff格式图片报错 #64

Open
collaborator-one opened this issue Jul 20, 2021 · 1 comment
Open

解析tiff格式图片报错 #64

collaborator-one opened this issue Jul 20, 2021 · 1 comment

Comments

@collaborator-one
Copy link

tifToImg(path) {
console.log('-----------------');
// path = 'https://datacenter1-oss.oss-cn-shenzhen.aliyuncs.com/ifi_pic/EP/0016/268/EP0016268B1/zy/000001.tif'
path = '../../assets/000001.tif'
// var Tiff = require('tiff.js')
// console.log(Tiff);
// let imgBox = this.$refs.imgBox
var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', path);
xhr.onload = (e) => {
// console.log(e);
var tiff = new Tiff({buffer: xhr.response});
var url = tiff.toDataURL()
console.log(url);
return url
// let img = document.createElement('img')
// img.src = url
// img.style.width = width + 'px'
// img.style.height = height + 'px'
// container.append(img)
};
xhr.send();
},

代码中var tiff = new Tiff({buffer: xhr.response});这句话报错如下
Uncaught TypeError: Cannot read property 'slice' of null
at r (tiff.min.js?e97c:78)
at eval (tiff.min.js?e97c:78)
at loadModule (tiff.min.js?e97c:78)
at Function.Lb.initialize (tiff.min.js?e97c:78)
at new Lb (tiff.min.js?e97c:78)
at XMLHttpRequest.xhr.onload (imgesist.vue?053e:194)

@feiaaa
Copy link

feiaaa commented Nov 10, 2021

#66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants