Fix #990: Display full-resolution embedded jpg from CR3 files
[geeqie.git] / src / image-load.cc
index 8516ef2..44db91e 100644 (file)
@@ -1008,7 +1008,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                        }
                else
                        {
-                       il->mapped_file = exif_get_preview(exif, (guint *)&il->bytes_total, 0, 0); /* get the largest available preview image or NULL for normal images*/
+                       il->mapped_file = libraw_get_preview(il, (guint *)&il->bytes_total);
 
                        if (il->mapped_file)
                                {
@@ -1020,25 +1020,27 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                                        }
                                else
                                        {
-                                       il->preview = IMAGE_LOADER_PREVIEW_EXIF;
+                                       il->preview = IMAGE_LOADER_PREVIEW_LIBRAW;
                                        }
                                }
                        }
 
-               /* If exiv2 does not find a thumbnail, try libraw (which may be slower) */
+               /* If libraw does not find a thumbnail, try exiv2 */
                if (!il->mapped_file)
                        {
-                       il->mapped_file = libraw_get_preview(il, (guint *)&il->bytes_total);
+                       il->mapped_file = exif_get_preview(exif, (guint *)&il->bytes_total, 0, 0); /* get the largest available preview image or NULL for normal images*/
 
                        if (il->mapped_file)
                                {
+                               /* 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_LIBRAW;
+                                       il->preview = IMAGE_LOADER_PREVIEW_EXIF;
                                        }
                                }
                        }