diff --git a/lib/output.js b/lib/output.js index 0e72d445..09c3b520 100644 --- a/lib/output.js +++ b/lib/output.js @@ -575,7 +575,7 @@ function tile (options) { if (options.overlap > this.options.tileSize) { throw is.invalidParameterError('overlap', `<= size (${this.options.tileSize})`, options.overlap); } - this.options.tileOverlap = tile.overlap; + this.options.tileOverlap = options.overlap; } else { throw is.invalidParameterError('overlap', 'integer between 0 and 8192', options.overlap); } diff --git a/package.json b/package.json index a01a73f6..33572764 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,8 @@ "Jordan Prudhomme ", "Ilya Ovdin ", "Andargor ", - "Paul Neave " + "Paul Neave ", + "Brendan Kennedy " ], "scripts": { "install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)", diff --git a/test/unit/tile.js b/test/unit/tile.js index a3aad2d7..00c24e5e 100644 --- a/test/unit/tile.js +++ b/test/unit/tile.js @@ -91,6 +91,29 @@ const assertGoogleTiles = function (directory, expectedTileSize, expectedLevels, }); }; +// Verifies tiles at specified level in a given output directory are > size+overlap +const assertTileOverlap = function (directory, tileSize, done) { + // Get sorted levels + const levels = fs.readdirSync(directory).sort((a, b) => a - b); + // Select the highest tile level + const highestLevel = levels[levels.length - 1]; + // Get sorted tiles from greatest level + const tiles = fs.readdirSync(path.join(directory, highestLevel)).sort(); + // Select a tile from the approximate center of the image + const squareTile = path.join(directory, highestLevel, tiles[Math.floor(tiles.length / 2)]); + + sharp(squareTile).metadata(function (err, metadata) { + if (err) { + throw err; + } else { + // Tile with an overlap should be larger than original size + assert.strictEqual(true, metadata.width > tileSize); + assert.strictEqual(true, metadata.height > tileSize); + done(); + } + }); +}; + describe('Tile', function () { it('Valid size values pass', function () { [1, 8192].forEach(function (size) { @@ -297,7 +320,9 @@ describe('Tile', function () { assert.strictEqual(2225, info.height); assert.strictEqual(3, info.channels); assert.strictEqual('undefined', typeof info.size); - assertDeepZoomTiles(directory, 512 + (2 * 16), 13, done); + assertDeepZoomTiles(directory, 512 + (2 * 16), 13, function () { + assertTileOverlap(directory, 512, done); + }); }); }); });