SF Bugs#132: Fix to correctly open GPX files in Windows via double click.
Previously in jpg.c there was no check for magic_load() result in Windows
(and the path to the magic database file was not correct).
So somehow when opening a file the 'is a JPG' test would return true when it is a GPX file,
thus leading to using the GPX file name as an image name.
Commonize the magic library processing so the correct location of the magic database is used for JPG tests,
with better tracing of error conditions.