Referencing https://github.com/seattlerb/image_science/issues/21 it appears that LibJPEG/jdmarker.c line 946 calls WARNMS2 whenever there is extraneous bytes in the jpeg header. But... it's just a warning. Unfortunately, the way freeimage wires up to libjpeg, it seems that it boils up to whatever is registered with FreeImage_SetOutputMessage.
The documentation for that function clearly states that it is to be used for errors: "When a certain bitmap cannot be loaded or saved there is usually an explanation for it. ... Whenever something fails in FreeImage internally a log-string is generated, which can be captured by an application driving FreeImage."
My ruby library image_science uses that to raise exceptions but it appears that it is now being used for both errors and warnings. This seems like an overloaded function now. Is there a way to turn OFF warning messages from boiling up to the error handler function I've registered? This is causing crashes in user code when it need not do so.