Fix #818: Latest version Cant' display the DNG files, previous were OK
authorColin Clark <colin.clark@cclark.uk>
Sat, 29 May 2021 08:02:48 +0000 (09:02 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sat, 29 May 2021 08:02:48 +0000 (09:02 +0100)
https://github.com/BestImageViewer/geeqie/issues/818

For the images in the bug report, Exiv2 returns a pointer to a section
that is not a jpeg.

Include a check that a jpeg has been found.

Libraw >= 0.20 will display these files.

src/image-load.c

index 3a5efc2..e6913ff 100644 (file)
@@ -1033,7 +1033,16 @@ static gboolean image_loader_setup_source(ImageLoader *il)
 
                        if (il->mapped_file)
                                {
-                               il->preview = IMAGE_LOADER_PREVIEW_EXIF;
+                               /* Both exiv2 and libraw sometimes return a pointer to a file
+                                * section that is not a jpeg */
+                               if (!(il->mapped_file[0] == 0xFF && il->mapped_file[1] == 0xD8))
+                                       {
+                                       il->mapped_file = NULL;
+                                       }
+                               else
+                                       {
+                                       il->preview = IMAGE_LOADER_PREVIEW_EXIF;
+                                       }
                                }
                        }
 
@@ -1044,7 +1053,14 @@ static gboolean image_loader_setup_source(ImageLoader *il)
 
                        if (il->mapped_file)
                                {
-                               il->preview = IMAGE_LOADER_PREVIEW_LIBRAW;
+                               if (!(il->mapped_file[0] == 0xFF && il->mapped_file[1] == 0xD8))
+                                       {
+                                       il->mapped_file = NULL;
+                                       }
+                               else
+                                       {
+                                       il->preview = IMAGE_LOADER_PREVIEW_LIBRAW;
+                                       }
                                }
                        }