Skip to content

Commit 896e80d

Browse files
committed
win32: Show TIFF warnings on console
Showing them in a window (default) is not acceptable for a console application like Tesseract which must be able to work in batch mode. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 669c739 commit 896e80d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

api/tesseractmain.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@
3333
#include "openclwrapper.h"
3434
#include "osdetect.h"
3535

36+
#if defined(_WIN32)
37+
38+
#include <tiffio.h>
39+
#include <windows.h>
40+
41+
static void Win32WarningHandler(const char* module, const char* fmt,
42+
va_list ap) {
43+
if (module != NULL) {
44+
fprintf(stderr, "%s: ", module);
45+
}
46+
fprintf(stderr, "Warning, ");
47+
vfprintf(stderr, fmt, ap);
48+
fprintf(stderr, ".\n");
49+
}
50+
51+
#endif /* _WIN32 */
52+
3653
void PrintVersionInfo() {
3754
char *versionStrP;
3855

@@ -352,6 +369,11 @@ int main(int argc, char **argv) {
352369
int arg_i = 1;
353370
tesseract::PageSegMode pagesegmode = tesseract::PSM_AUTO;
354371

372+
#if defined(_WIN32)
373+
/* Show libtiff warnings on console (not in GUI). */
374+
TIFFSetWarningHandler(Win32WarningHandler);
375+
#endif /* _WIN32 */
376+
355377
ParseArgs(argc, argv,
356378
&lang, &image, &outputbase, &datapath,
357379
&list_langs, &print_parameters,

0 commit comments

Comments
 (0)