}
}
private JpegImageData getJpegRawImageData(final ByteSource byteSource,
final TiffDirectory directory) throws ImageReadException, IOException {
final ImageDataElement element = directory.getJpegRawImageDataElement();
final long offset = element.offset;
int length = element.length;
// In case the length is not correct, adjust it and check if the last read byte actually is the end of the image
if (offset + length > byteSource.getLength()) {
length = (int) (byteSource.getLength() - offset);