]> git.lyx.org Git - features.git/commitdiff
Fix clipping for vector formats and when exporting from command line
authorEnrico Forestieri <forenr@lyx.org>
Fri, 25 Sep 2020 19:25:40 +0000 (21:25 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 25 Sep 2020 19:25:40 +0000 (21:25 +0200)
This amends ea81faa9 that only took into account the postscript format
and did not consider that without GUI an image is not available even if
if it is actually cached. In this case we load the image for obtaining
its dimensions in order to correct the clipping bounding box.

src/insets/InsetGraphics.cpp
status.23x

index 88ee9a032082afb73eb2d96fec79103c33b90be0..cf5f9ac94b75e011b87a30df78ed8552f56c0c6c 100644 (file)
@@ -93,6 +93,7 @@ TODO
 #include "support/Systemcall.h"
 
 #include <QProcess>
+#include <QtGui/QImage>
 
 #include <algorithm>
 #include <sstream>
@@ -320,13 +321,13 @@ void InsetGraphics::outBoundingBox(graphics::BoundingBox & bbox) const
 
        FileName const file(params().filename.absFileName());
 
-       // No correction is necessary for a postscript image
+       // No correction is necessary for a vector image
        bool const zipped = theFormats().isZippedFile(file);
        FileName const unzipped_file = zipped ? unzipFile(file) : file;
        string const format = theFormats().getFormatFromFile(unzipped_file);
        if (zipped)
                unzipped_file.removeFile();
-       if (Formats::isPostScriptFileFormat(format))
+       if (theFormats().getFormat(format)->vectorFormat())
                return;
 
        // Get the actual image dimensions in pixels
@@ -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;
 
index 17fcf4c57954bf851f59198cff31d371662bb85e..82b1f2a1c1c38a0cadfb38f16dcf6fe9f86b7068 100644 (file)
@@ -70,6 +70,9 @@ What's new
 
 - Fix output of titles in branches and other insets (follow-up to bug 11787).
 
+- Fix clipping of vector images and when exporting from command line
+  (follow-up to bug 11180).
+
 
 * USER INTERFACE