Skip to content

Commit

Permalink
Merge pull request #89 from melissalinkert/tile-16
Browse files Browse the repository at this point in the history
Force tile sizes to be a multiple of 16
  • Loading branch information
chris-allan authored Dec 5, 2022
2 parents c58ecec + c86c3c1 commit 82b9536
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/java/com/glencoesoftware/pyramid/PyramidSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ public void describePyramid(ZarrGroup reader, OMEPyramidStore metadata)
descriptor.sizeY = dimensions[dimensions.length - 2];
descriptor.tileSizeX = blockSizes[blockSizes.length - 1];
descriptor.tileSizeY = blockSizes[blockSizes.length - 2];

if (descriptor.tileSizeX % 16 != 0) {
LOG.debug("Tile width ({}) not a multiple of 16; correcting",
descriptor.tileSizeX);
descriptor.tileSizeX += (16 - (descriptor.tileSizeX % 16));
}
if (descriptor.tileSizeY % 16 != 0) {
LOG.debug("Tile height ({}) not a multiple of 16; correcting",
descriptor.tileSizeY);
descriptor.tileSizeY += (16 - (descriptor.tileSizeY % 16));
}

descriptor.numberOfTilesX =
getTileCount(descriptor.sizeX, descriptor.tileSizeX);
descriptor.numberOfTilesY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,19 @@ public void testEdgePaddingUint16() throws Exception {
public void testOddTileSize() throws Exception {
input = fake("pixelType", "uint16");
assertBioFormats2Raw("-w", "17", "-h", "19");
assertTool();
assertTool("--compression", "raw");
iteratePixels();

try (TiffParser parser = new TiffParser(outputOmeTiff.toString())) {
IFDList mainIFDs = parser.getMainIFDs();
Assert.assertEquals(1, mainIFDs.size());
int tileSize = 32 * 32 * 2;
long[] tileByteCounts = mainIFDs.get(0).getStripByteCounts();
Assert.assertEquals(256, tileByteCounts.length);
for (long count : tileByteCounts) {
Assert.assertEquals(tileSize, count);
}
}
}

/**
Expand Down

0 comments on commit 82b9536

Please sign in to comment.