Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force tile sizes to be a multiple of 16 #89

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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