#include "config.h"
#endif
#include "jpg.h"
+#include "file_magic.h"
+#ifdef VIK_CONFIG_GEOTAG
#include "geotag_exif.h"
-
-#ifdef HAVE_MAGIC_H
-#include <magic.h>
#endif
/**
* a_jpg_magic_check:
* @filename: The file
*
- * Returns: Whether the file is a JPG.
- * Uses Magic library if available to determine the jpgness.
- * Otherwise uses a rudimentary extension name check.
+ * Returns: Whether the file is a JPG
*/
gboolean a_jpg_magic_check ( const gchar *filename )
{
- gboolean is_jpg = FALSE;
-#ifdef HAVE_MAGIC_H
- magic_t myt = magic_open ( MAGIC_CONTINUE|MAGIC_ERROR|MAGIC_MIME );
- if ( myt ) {
-#ifdef WINDOWS
- // We have to 'package' the magic database ourselves :(
- // --> %PROGRAM FILES%\Viking\magic.mgc
- magic_load ( myt, "magic.mgc" );
-#else
- // Use system default
- magic_load ( myt, NULL );
-#endif
- const char* magic = magic_file (myt, filename);
- if ( g_strcmp0 (magic, "image/jpeg; charset=binary") == 0 )
- is_jpg = TRUE;
-
- magic_close ( myt );
- }
- else
-#endif
- is_jpg = a_file_check_ext ( filename, ".jpg" );
-
- return is_jpg;
+ return file_magic_check ( filename, "image/jpeg", ".jpg" );
}
/**
create_layer = TRUE;
}
- gchar *name;
- VikWaypoint *wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode (vvp), &name );
+ gchar *name = NULL;
+ VikWaypoint *wp = NULL;
+#ifdef VIK_CONFIG_GEOTAG
+ wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode (vvp), &name );
+#endif
if ( wp ) {
// Create name if geotag method didn't return one
if ( !name )