]> git.lyx.org Git - features.git/commitdiff
Use correct bounding box when exporting from command line
authorEnrico Forestieri <forenr@lyx.org>
Fri, 25 Sep 2020 18:58:40 +0000 (20:58 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 25 Sep 2020 18:58:40 +0000 (20:58 +0200)
Without GUI an image is not available even if it is actually cached.
In this case we load the image for obtaining its dimensions in order
to correct the clipping bounding box.

This amends 380f34a1.

src/insets/InsetGraphics.cpp

index 957e002685efcb183f077afd6638da73d0897cae..b20e9a71b9c41780f75ed85cef2950d618b7a721 100644 (file)
@@ -93,6 +93,7 @@ TODO
 #include "support/Systemcall.h"
 
 #include <QProcess>
+#include <QtGui/QImage>
 
 #include <algorithm>
 #include <sstream>
@@ -340,6 +341,12 @@ void InsetGraphics::outBoundingBox(graphics::BoundingBox & bbox) const
                        height = image->height();
                }
        }
+       // Even if cached, the image is not loaded without GUI
+       if  (width == 0 && height == 0) {
+               QImage image(toqstr(file.absFileName()));
+               width  = image.width();
+               height = image.height();
+       }
        if (width == 0 || height == 0)
                return;