/
test.html
48 lines (37 loc) · 1.49 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>TIFF test</title>
<script src="tiff.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
var prepareTIFF = function() {
var file = document.getElementById( "tiff-file" ).files[0];
if (file.type !== 'image/tiff') {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var canvas = document.getElementById("tiff-image");
var canvasParent = canvas.parentNode;
var tiffParser = new TIFFParser();console.log( tiffParser );
var tiffCanvas = tiffParser.parseTIFF(e.target.result, canvas);
console.log( tiffCanvas );
canvasParent.replaceChild(tiffCanvas, canvas);
};
reader.readAsArrayBuffer( file );
}
</script>
</head>
<body>
<form name="tiff-parser" method="post" enctype="multipart/form-data" style="margin: 10% auto auto; text-align: center;">
<input type="file" name="tiff-file" id="tiff-file" accept="image/tiff" required onchange="prepareTIFF();" />
<input type="button" name="parse" value="Parse TIFF" onclick="prepareTIFF();" />
</form>
<canvas id="tiff-image" style="display: block; max-width: 95%; margin: 2em auto; border: 1px dashed magenta; padding: 0px; background-color: black"></canvas>
</body>
</html>