try {
dir = new TIFFDirectory(seekable, pageIndex);
} catch (IllegalArgumentException iae) {
String errorMessage = MessageFormat.format(
"Subimage {0} does not exist.", new Object[] {new Integer(pageIndex)});
throw new SubImageNotFoundException(errorMessage);
}
int width = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH);
int height = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH);
ImageSize size = new ImageSize();
size.setSizeInPixels(width, height);