-
Notifications
You must be signed in to change notification settings - Fork 30
/
test.html
59 lines (44 loc) · 1.75 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
49
50
51
52
53
54
55
56
57
58
59
<!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 files = document.getElementById( "tiff-file" ).files;
var file = files[0];
if (files.length < 1 || file.type !== 'image/tiff') {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var canvas = document.getElementById("tiff-image");
var canvasParent = canvas.parentNode;
// Load the TIFF parser.
var tiffParser = new TIFFParser();
console.log( tiffParser );
// Parse the TIFF image.
var tiffCanvas = tiffParser.parseTIFF(e.target.result, canvas);
// Make it clear that we've loaded the image.
tiffCanvas.style.borderStyle = "solid";
console.log( tiffCanvas );
// Put the parsed image in the page.
canvasParent.replaceChild(tiffCanvas, canvas);
};
reader.readAsArrayBuffer( file );
}
</script>
</head>
<body onload="prepareTIFF();">
<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: #FFEEFF;"></canvas>
</body>
</html>