Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TiffImage {
- constructor(url) {
- this.imageURL = boardType;
- }
- this.width;
- this.height;
- this.canvas;
- this.xResolution;
- this.yResolution;
- }
- async loadImage() {
- // retrieve tiff and convert it to an html5 canvas
- return fetch(this.imageURL)
- .then((response) => {
- return response.arrayBuffer();
- })
- .then((buffer) => {
- // handle tiff image
- let tiff = new Tiff({buffer: buffer});
- this.width = tiff.width();
- this.height = tiff.height();
- // try to grab resolutions
- this.xResolution = tiff.getField(282);
- this.yResolution = tiff.getField(283);
- console.log('xRes: ' + this.xResolution);
- // prints 'xRes: 1098514432'
- console.log('yRes: ' + this.yResolution);
- // prints 'yRes: 1081737216'
- console.log('xRes as bin: ' + this.xResolution.toString(2);
- // prints 'xRes as bin: 1000001011110100000000000000000'
- console.log('yRes as bin: ' + this.yResolution.toString(2);
- // prints 'yRes as bin: 1000000011110100000000000000000'
- this.canvas = tiff.toCanvas();
- // do stuff with image
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement