Question

I need help to stop annoying warnings displayed on my console .

I'm getting the following warnings using an application that detects corrupted images . The application works as expected but these messages appear.

ReadDirectory: Warning, C:\find corrupted images\a.TIF: unknown field with tag 50701 (0xc60d) encountered fillStrip: C:\find corrupted images\b.TIF: Read error at scanlin e -1; got 7115 bytes, expected 10130 ReadDirectory: Warning, C:\find corrupted images\c: unknown field wit h tag 33885 (0x845d) encountered ReadDirectory: Warning, C:\find corrupted images\d: unknown field wit h tag 50701 (0xc60d) encountered ReadDirectory: Warning, C:\find corrupted images\e:

LibJpeg: Warning, Corrupt JPEG data: 11021 extraneous bytes before marker 0xD8 LibJpeg: Unexpected error

OJPEGSetupDecode: Warning, Depreciated and troublesome old-style JPEG compressio n mode, please convert to new-style JPEG compression and notify vendor of writin g software OJPEGReadHeaderInfoSecStreamSof:

ReadDirectory: Warning, SamplesPerPixel tag is missing, assuming correct Samples PerPixel value is 1

tif: unknown field with tag 50701 (0xc60d) encountered ReadDirectory: Warning, SamplesPerPixel tag is missing, assuming correct Samples PerPixel value is 1

Any ideas how to stop these messages appearing ?

Thanks in advance

No correct solution

OTHER TIPS

You should provide your own error handler to the library if you don't want warnings to appear in console.

Start by creating class which inherits from TiffErrorHandler and overloads WarningHandler and WarningHandlerEx methods. Basically, you could do nothing in these methods.

Then set an instance of you class as the error handler for the library with SetErrorHandler method. The method is static and you can set error handler before opening an image.

You need to override the WarningHandler() and WarningHandlerExt() methods with the correct signature:

    public class DisableErrorHandler : TiffErrorHandler
    {
        public override void WarningHandler(Tiff tif, string method, string format, params object[] args)
        {
           // do nothing, ie, do not write warnings to console
        }
        public override void WarningHandlerExt(Tiff tif, object clientData, string method, string format, params object[] args) 
        {
           // do nothing ie, do not write warnings to console
        }
    }

By having the correct method signature and method names the override keyword is required. Once you override the methods successfully, then setting the error handler to your new methods will work correctly:

    Tiff.SetErrorHandler(new DisableErrorHandler());
    // now no warnings will be sent to console

    using (Tiff tiff = Tiff.Open(fn, "r"))
    { .....

Notice we have only overridden the warning handlers. You could of course override the error handlers as well. Reference:

https://bitmiracle.github.io/libtiff.net/help/api/BitMiracle.LibTiff.Classic.TiffErrorHandler.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top