Display image as .tiff or .tif

Not how to do this, and consulted, but did not reach if I can help.

try something like this:

    var reader = new FileReader();
reader.onload = function(event) {
    var dataUri = event.target.result,
        context = document.getElementById("mycanvas").getContext("2d"),
        img     = new Image();

    // wait until the image has been fully processed
    img.onload = function() {
        context.drawImage(img, 100, 100);
    };
img.src = 'url_imagen';
};

reader.onerror = function(event) {
    console.error("File could not be read! Code " + event.target.error.code);
};

reader.readAsDataURL(file);

When all the contributions are realized, but try, and if it works.

Point run to desert, poker images that have jpg my permission cause the following error:

TIFFReadDirectory: warning, unknown field with tag 347 (0x15b). tiff_min.js (línea 103) 1.tiff: JPEG compression support not configured. tiff_min.js (línea 103) 1.tiff: Sorry, the requested compression method is not configured. tiff_min.js (línea 103) uncaught exception: [object Object]

Probe Code:

Tiff.initialize({TOTAL_MEMORY: 19777216 * 10});
        var xhr = new XMLHttpRequest();
        xhr.responseType = 'arraybuffer';
        xhr.open('GET', url);
        xhr.onload = function (e) {
            var tiff = new Tiff({buffer: xhr.response,height:450});
            var canvas = tiff.toCanvas();
            //canvas.width = 700;
            //canvas.height = 450;
            div.html(canvas);
            msn('Imagen cargada', "Imagen cargada con exito.");
        };
        xhr.send();
+4
source share
2 answers

Tiff .

"tiff.min.js" https://github.com/seikichi/tiff.js "src".

angular.json "scripts": ["src/tiff.min.js"]

"" → "" → "" → "" → ""

ts :

declare var Tiff: any;  # declared globally outside the class

# inside the component class
let xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', 'src_of_image_to_be_displayed');
xhr.onload = (e) => {
  let tiff = new Tiff({buffer: xhr.response});
  let canvas = tiff.toCanvas();
  document.body.append(canvas); # append to an div element 
}
xhr.send();
0

All Articles