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

Suggest noting that libtiff must have been compiled with JPEG compression support for tests to run correctly #720

Open
johnsonea opened this issue Nov 1, 2023 · 4 comments

Comments

@johnsonea
Copy link

If libtiff has NOT been installed with JPEG compression (i.e., ./configure --enable-jpeg --enable-old-jpeg), then ioformats_reg gives errors on four images (FILE_8BPP_1, FILE_8BPP_2, FILE_8BPP_3, "testbuffer.tif") .

A note or warning in the leptonica documentation that JPEG must be enabled in libtiff would be helpful. Thx!

(pngio_reg also gave errors that disappeared when libtiff was recomplied with JPEGs upport, but I did not investigate closely to see where or why.)

@johnsonea johnsonea changed the title Suggest Suggest noting that libtiff must have been compiled with JPEG compression support for tests to run correctly Nov 1, 2023
@DanBloomberg
Copy link
Owner

Thank you. I will amend the README.html to note that libjpeg is required with libtiff.
Also:

  • modify tiffio.c to require libjpeg
  • modify tiffiostub.c to be used if libjpeg is not defined
  • modify ioFormatTest() to require libjpeg for tiff tests.

@stweil
Copy link
Collaborator

stweil commented Nov 1, 2023

I'm not sure whether that's the best solution for the reported issue. TIFF files can be uncompressed, and such files work well with Leptonica and a libtiff without JPEG support.

DanBloomberg added a commit that referenced this issue Nov 1, 2023
* Also fix colorcontent_reg to work with different jpeg libraries
* Fixes Issue #719 and Issue #720, reported by @johnsonea.
* Documentation change for Issue #717, reported by @kloczek.
@DanBloomberg
Copy link
Owner

It seems to me quite complicated to not require jpeg support for tiff, because many of the functions in tiffio.c accept the JPEG compression type as an argument. And because tiff, jpeg and png are the standard, expected libraries in the environment in which tesseract is running, it doesn't seem like a stretch to require jpeg for read/write of tiff.

Also, for maintenance it is important to do everything possible to avoid problems with building that happen because functions asked for are missing. And if there is a failure at runtime, it's good to have a simple error message that says something to the effect that tiff is not supported. I could expand that error message in tiffiostub.c if you think it would be useful in the event of a runtime error to point out the necessity of having both libtiff and libjpeg.

@johnsonea
Copy link
Author

johnsonea commented Nov 1, 2023

To diagnose why some TIFF images were giving an error, I temporarily edited libtiff's tif_getimage.c to add an fprintf(stderr,...,emsg) call in function TIFFReadRGBAImageOriented to see what the real error was. That was obviously a hack and not appropriate for real operation.

libtiff does have an error mechanism that -- if you can figure out how to use it's TIFFError*, TIFFErrorHandler* and TIFFSetErrorHandler* functions (I couldn't decipher how to use them) -- might provide a significantly more precise error message within leptonica's tiff* functions. That would be very helpful to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants