2020.12.11 21:43 "Re: [Tiff] SIGSEGV within TIFFGetField()", by Paavo
One thing which has frustrated me with custom tags is that (AFAICT) you can only register a custom tag on an open TIFF handle, which means you still get a bunch of warnings about unknown tags when you open the file and it reads the first IFD, before you have a chance to do the registration. Anyone know if there’s a way around that?
Sure, you register your own warning handler and ignore those warnings:
extern "C" void MyLibtiffWarningHandler(thandle_t user_data, const char* module, const char* fmt, va_list ap) {
if (strcmp(fmt, "Unknown field with tag %d (0x%x) encountered")==0) {
// Unknown tags are output elsewhere, no need to issue warnings.
return;
}
if (strcmp(fmt, "Invalid TIFF directory; tags are not sorted in ascending order") == 0) {
// so? what the user must do with this message?
return;
}
// log the warning properly
}
TIFFSetWarningHandlerExt(MyLibtiffWarningHandler);
// switch off default warning handler for reducing console noise.
TIFFSetWarningHandler(nullptr);
Cheers
Paavo