--- a/src/hugin_base/panodata/SrcPanoImage.cpp
+++ b/src/hugin_base/panodata/SrcPanoImage.cpp
@@ -297,6 +297,15 @@
         return false;
     };
 
+    // if width==2*height assume equirectangular image
+    if (getWidth() == 2 * getHeight())
+    {
+        FileMetaData metaData = getFileMetadata();
+        metaData["projection"] = "equirectangular";
+        metaData["HFOV"] = "360";
+        setFileMetadata(metaData);
+    };
+
     Exiv2::Image::AutoPtr image;
     try {
         image = Exiv2::ImageFactory::open(filename.c_str());
@@ -310,121 +319,7 @@
     }
 
     image->readMetadata();
-    Exiv2::ExifData &exifData = image->exifData();
-    if (exifData.empty()) {
-        std::cerr << "Unable to read EXIF data from opened file:" << filename << std::endl;
-        return false;
-    }
-
-    setExifExposureTime(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::exposureTime(exifData)));
-    setExifAperture(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::fNumber(exifData)));
-    
-    //read exposure mode
-    setExifExposureMode(Exiv2Helper::getExiv2ValueLong(exifData, "Exif.Photo.ExposureMode"));
-
-    // read ISO from EXIF or makernotes
-    setExifISO(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::isoSpeed(exifData)));
-
-    setExifMake(Exiv2Helper::getExiv2ValueString(exifData, Exiv2::make(exifData)));
-    setExifModel(Exiv2Helper::getExiv2ValueString(exifData, Exiv2::model(exifData)));
-
-    //reading lens
-    setExifLens(Exiv2Helper::getLensName(exifData));
-
-    long orientation = Exiv2Helper::getExiv2ValueLong(exifData, "Exif.Image.Orientation");
-    if (orientation>0 && trustExivOrientation())
-    {
-        switch (orientation) {
-            case 3:  // rotate 180
-                roll = 180;
-                break;
-            case 6: // rotate 90
-                roll = 90;
-                break;
-            case 8: // rotate 270
-                roll = 270;
-                break;
-            default:
-                break;
-        }
-    }
-
-    long pixXdim = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.PixelXDimension");
-    long pixYdim = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.PixelYDimension");
-
-    if (pixXdim !=0 && pixYdim !=0 )
-    {
-        double ratioExif = pixXdim/(double)pixYdim;
-        double ratioImage = getWidth()/(double)getHeight();
-        if (fabs( ratioExif - ratioImage) > 0.1)
-        {
-            // Image has been modified without adjusting exif tags.
-            // Assume user has rotated to upright pose
-            roll = 0;
-        }
-    }
-    // save for later
-    setExifOrientation(roll);
-    
-    double cropFactor=Exiv2Helper::getCropFactor(exifData, getWidth(), getHeight());
-    DEBUG_DEBUG("cropFactor: " << cropFactor);
-
-    float eFocalLength = Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::focalLength(exifData));
-    float eFocalLength35 = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.FocalLengthIn35mmFilm");
-    float focalLength=0;
-    //The various methods to detmine crop factor
-    if (eFocalLength > 0 && cropFactor > 0)
-    {
-        // user provided crop factor
-        focalLength = eFocalLength;
-    }
-    else
-    {
-        if (eFocalLength35 > 0 && eFocalLength > 0)
-        {
-            cropFactor = eFocalLength35 / eFocalLength;
-            focalLength = eFocalLength;
-        }
-        else
-        {
-            if (eFocalLength35 > 0)
-            {
-                // 35 mm equiv focal length available, crop factor unknown.
-                // do not ask for crop factor, assume 1.  Probably a full frame sensor
-                cropFactor = 1;
-                focalLength = eFocalLength35;
-            }
-            else
-            {
-                if (eFocalLength > 0 && cropFactor <= 0)
-                {
-                    // need to redo, this time with crop
-                    focalLength = eFocalLength;
-                    cropFactor = 0;
-                }
-            };
-        };
-    };
-    setExifFocalLength(focalLength);
-    setExifFocalLength35(eFocalLength35);
-    setExifCropFactor(cropFactor);
-
-    setExifDistance(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::subjectDistance(exifData)));
-    setExifDate(Exiv2Helper::getExiv2ValueString(exifData, "Exif.Photo.DateTimeOriginal"));
-
-    double redBalance, blueBalance;
-    Exiv2Helper::readRedBlueBalance(exifData, redBalance, blueBalance);
-    setExifRedBalance(redBalance);
-    setExifBlueBalance(blueBalance);
-
-    // if width==2*height assume equirectangular image
-    if (getWidth() == 2 * getHeight())
-    {
-        FileMetaData metaData = getFileMetadata();
-        metaData["projection"] = "equirectangular";
-        metaData["HFOV"] = "360";
-        setFileMetadata(metaData);
-    };
+
     // look into XMP metadata
     Exiv2::XmpData& xmpData = image->xmpData();
     if (!xmpData.empty())
@@ -511,7 +406,114 @@
             // just to catch error when image contains no GPano tags
             std::cerr << "Error reading GPano tags from " << filename << "(" << e.what() << ")" << std::endl;
         };
-    }
+    };
+
+    Exiv2::ExifData &exifData = image->exifData();
+    if (exifData.empty()) {
+        std::cerr << "Unable to read EXIF data from opened file:" << filename << std::endl;
+        return !getFileMetadata().empty();
+    }
+
+    setExifExposureTime(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::exposureTime(exifData)));
+    setExifAperture(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::fNumber(exifData)));
+    
+    //read exposure mode
+    setExifExposureMode(Exiv2Helper::getExiv2ValueLong(exifData, "Exif.Photo.ExposureMode"));
+
+    // read ISO from EXIF or makernotes
+    setExifISO(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::isoSpeed(exifData)));
+
+    setExifMake(Exiv2Helper::getExiv2ValueString(exifData, Exiv2::make(exifData)));
+    setExifModel(Exiv2Helper::getExiv2ValueString(exifData, Exiv2::model(exifData)));
+
+    //reading lens
+    setExifLens(Exiv2Helper::getLensName(exifData));
+
+    long orientation = Exiv2Helper::getExiv2ValueLong(exifData, "Exif.Image.Orientation");
+    if (orientation>0 && trustExivOrientation())
+    {
+        switch (orientation) {
+            case 3:  // rotate 180
+                roll = 180;
+                break;
+            case 6: // rotate 90
+                roll = 90;
+                break;
+            case 8: // rotate 270
+                roll = 270;
+                break;
+            default:
+                break;
+        }
+    }
+
+    long pixXdim = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.PixelXDimension");
+    long pixYdim = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.PixelYDimension");
+
+    if (pixXdim !=0 && pixYdim !=0 )
+    {
+        double ratioExif = pixXdim/(double)pixYdim;
+        double ratioImage = getWidth()/(double)getHeight();
+        if (fabs( ratioExif - ratioImage) > 0.1)
+        {
+            // Image has been modified without adjusting exif tags.
+            // Assume user has rotated to upright pose
+            roll = 0;
+        }
+    }
+    // save for later
+    setExifOrientation(roll);
+    
+    double cropFactor=Exiv2Helper::getCropFactor(exifData, getWidth(), getHeight());
+    DEBUG_DEBUG("cropFactor: " << cropFactor);
+
+    float eFocalLength = Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::focalLength(exifData));
+    float eFocalLength35 = Exiv2Helper::getExiv2ValueLong(exifData,"Exif.Photo.FocalLengthIn35mmFilm");
+    float focalLength=0;
+    //The various methods to detmine crop factor
+    if (eFocalLength > 0 && cropFactor > 0)
+    {
+        // user provided crop factor
+        focalLength = eFocalLength;
+    }
+    else
+    {
+        if (eFocalLength35 > 0 && eFocalLength > 0)
+        {
+            cropFactor = eFocalLength35 / eFocalLength;
+            focalLength = eFocalLength;
+        }
+        else
+        {
+            if (eFocalLength35 > 0)
+            {
+                // 35 mm equiv focal length available, crop factor unknown.
+                // do not ask for crop factor, assume 1.  Probably a full frame sensor
+                cropFactor = 1;
+                focalLength = eFocalLength35;
+            }
+            else
+            {
+                if (eFocalLength > 0 && cropFactor <= 0)
+                {
+                    // need to redo, this time with crop
+                    focalLength = eFocalLength;
+                    cropFactor = 0;
+                }
+            };
+        };
+    };
+    setExifFocalLength(focalLength);
+    setExifFocalLength35(eFocalLength35);
+    setExifCropFactor(cropFactor);
+
+    setExifDistance(Exiv2Helper::getExiv2ValueDouble(exifData, Exiv2::subjectDistance(exifData)));
+    setExifDate(Exiv2Helper::getExiv2ValueString(exifData, "Exif.Photo.DateTimeOriginal"));
+
+    double redBalance, blueBalance;
+    Exiv2Helper::readRedBlueBalance(exifData, redBalance, blueBalance);
+    setExifRedBalance(redBalance);
+    setExifBlueBalance(blueBalance);
 
     DEBUG_DEBUG("Results for:" << filename);
     DEBUG_DEBUG("Focal Length: " << getExifFocalLength());