diff --git a/meshroom/ui/components/filepath.py b/meshroom/ui/components/filepath.py index f15d9700..6c19e87f 100644 --- a/meshroom/ui/components/filepath.py +++ b/meshroom/ui/components/filepath.py @@ -2,7 +2,7 @@ # coding:utf-8 from meshroom.core import pyCompatibility -from PySide2.QtCore import QUrl +from PySide2.QtCore import QUrl, QFileInfo from PySide2.QtCore import QObject, Slot import os @@ -89,3 +89,8 @@ class FilepathHelper(QObject): if fileList: return fileList[0] return "" + + @Slot(QUrl, result=int) + def fileSizeMB(self, path): + """ Returns the file size in MB. """ + return QFileInfo(self.asStr(path)).size() / (1024*1024) diff --git a/meshroom/ui/qml/Viewer3D/MediaLoader.qml b/meshroom/ui/qml/Viewer3D/MediaLoader.qml index 38a50fd1..96bfc516 100644 --- a/meshroom/ui/qml/Viewer3D/MediaLoader.qml +++ b/meshroom/ui/qml/Viewer3D/MediaLoader.qml @@ -110,6 +110,14 @@ import Utils 1.0 MediaLoaderEntity { id: exrLoaderEntity Component.onCompleted: { + var fSize = Filepath.fileSizeMB(source) + if(fSize > 500) + { + // Do not load images that are larger than 500MB + console.warn("Viewer3D: Do not load the EXR in 3D as the file size is too large: " + fSize + "MB") + root.status = SceneLoader.Error; + return; + } // EXR loading strategy: // - [1] as a depth map var obj = Viewer3DSettings.depthMapLoaderComp.createObject(