Fix handling of single pages from multipage TIFF files (issue #2537)

That case now uses Leptonica to deliver the desired image instead of
using an inefficient loop in the Tesseract code.

See commit 54fafc4e2e which used similar
code in the past.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2019-07-04 15:56:57 +02:00
parent 08ca7b8416
commit 22fb70cb85

View File

@ -1037,10 +1037,14 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
int page = (tessedit_page_number >= 0) ? tessedit_page_number : 0;
size_t offset = 0;
for (; ; ++page) {
if (tessedit_page_number >= 0)
if (tessedit_page_number >= 0) {
page = tessedit_page_number;
pix = (data) ? pixReadMemTiff(data, size, page)
: pixReadTiff(filename, page);
} else {
pix = (data) ? pixReadMemFromMultipageTiff(data, size, &offset)
: pixReadFromMultipageTiff(filename, &offset);
}
if (pix == nullptr) break;
tprintf("Page %d\n", page + 1);
char page_str[kMaxIntSize];