Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 21, 2012
Matt Greer city41 made tiff.js Chrome compatible
-- got rid of default parameters (as cool as they are)
-- got rid of const (as nice as it is)
80c9069
Matt Greer city41 Fixed test.html to only load tiff once one is chosen 9a9291f
Gordon P. Hemsley Merge pull request #10 from city41/master
Fixes to tiff.js to work in Chrome
240644a
Showing with 14 additions and 8 deletions.
  1. +3 −3 test.html
  2. +11 −5 tiff.js
6 test.html
View
@@ -33,7 +33,7 @@
}
</script>
</head>
-<body onload="prepareTIFF();">
+<body>
<form name="tiff-parser" method="post" enctype="multipart/form-data" style="margin: 10% auto auto; text-align: center;">
@@ -42,7 +42,7 @@
</form>
-<canvas id="tiff-image" style="display: block; max-width: 95%; margin: 2em auto; border: 1px dashed magenta; padding: 0px;"></canvas>
+<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>
+</html>
16 tiff.js
View
@@ -41,7 +41,7 @@ TIFFParser.prototype = {
getFieldTagName: function (fieldTag) {
// See: http://www.digitizationguidelines.gov/guidelines/TIFF_Metadata_Final.pdf
// See: http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
- const fieldTagNames = {
+ var fieldTagNames = {
// TIFF Baseline
0x013B: 'Artist',
0x0102: 'BitsPerSample',
@@ -164,7 +164,7 @@ TIFFParser.prototype = {
},
getFieldTypeName: function (fieldType) {
- const fieldTypeNames = {
+ var fieldTypeNames = {
0x0001: 'BYTE',
0x0002: 'ASCII',
0x0003: 'SHORT',
@@ -204,7 +204,8 @@ TIFFParser.prototype = {
return fieldTypeLength;
},
- getBits: function (numBits, byteOffset, bitOffset = 0) {
+ getBits: function (numBits, byteOffset, bitOffset) {
+ bitOffset = bitOffset || 0;
var extraBytes = Math.floor(bitOffset / 8);
var newByteOffset = byteOffset + extraBytes;
var totalBits = bitOffset + numBits;
@@ -304,7 +305,10 @@ TIFFParser.prototype = {
return Math.floor((colorSample * multiplier) + (multiplier - 1));
},
- makeRGBAFillValue: function(r, g, b, a = 1.0) {
+ makeRGBAFillValue: function(r, g, b, a) {
+ if(typeof a === 'undefined') {
+ a = 1.0;
+ }
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
},
@@ -338,7 +342,9 @@ TIFFParser.prototype = {
}
},
- parseTIFF: function (tiffArrayBuffer, canvas = document.createElement("canvas")) {
+ parseTIFF: function (tiffArrayBuffer, canvas) {
+ canvas = canvas || document.createElement('canvas');
+
this.tiffDataView = new DataView(tiffArrayBuffer);
this.canvas = canvas;

No commit comments for this range

Something went wrong with that request. Please try again.