Skip to content

Commit 4df479d

Browse files
committed
prototype
1 parent e9175a5 commit 4df479d

10 files changed

+2440
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
.DS_Store

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
# is-geotiff
22
Super Light and Fast Method for Checking if a TIFF is a GeoTIFF
3+
4+
# install
5+
```bash
6+
npm install is-geotiff
7+
```
8+
9+
# usage
10+
```js
11+
const fs = require("fs");
12+
const isGeoTIFF = require("is-geotiff");
13+
14+
const buffer = fs.readFileSync("./example.tiff");
15+
16+
const { result } = isGeoTIFF({
17+
data: buffer,
18+
debug: false // set debug to true for increased logging
19+
});
20+
// result is true
21+
```

data/cog.tif

1 MB
Binary file not shown.

data/flower.jpg

28.4 KB
Loading

data/flower.tif

469 KB
Binary file not shown.

data/geo.tif

92.6 KB
Binary file not shown.

is-geotiff.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const hasBytes = require("has-bytes");
2+
3+
const GEOTIFF_TAGS = {
4+
GeoKeyDirectoryTag: [135, 175], // 0x87AF
5+
ModelPixelScaleTag: [14, 131], // 0x830E
6+
ModelTiepointTag: [130, 132], // 0x8482
7+
GeoDoubleParamsTag: [176, 135], // 0x87B0
8+
GeoAsciiParamsTag: [177, 135], // 0x87B1
9+
GDAL_NODATA: [129, 164] // 0xA481
10+
};
11+
12+
module.exports = ({
13+
data,
14+
debug = false,
15+
read_length = 1000,
16+
threshold = 3
17+
}) => {
18+
if (debug) console.log("[is-geotiff] starting with data", data);
19+
20+
const { found, result } = hasBytes({
21+
data,
22+
debug,
23+
end: read_length,
24+
sequences: GEOTIFF_TAGS,
25+
start: 0,
26+
threshold
27+
});
28+
if (debug) console.log("[is-geotiff] result from hasBytes is", result);
29+
30+
return { found, result, threshold };
31+
};

0 commit comments

Comments
 (0)