summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Dufour <nicoduf@yahoo.fr>2013-05-12 12:49:26 +0000
committerJazzyNico <nicoduf@yahoo.fr>2013-05-12 12:49:26 +0000
commit5a75b3f90a53941f04f32dc8f22c25f2f855ad2e (patch)
treec032185f29cab12ac026ce7926c74315fb80519d /src
parentFix for Bug #448872 (Changing the bounding box type in preferences does not u... (diff)
downloadinkscape-5a75b3f90a53941f04f32dc8f22c25f2f855ad2e.tar.gz
inkscape-5a75b3f90a53941f04f32dc8f22c25f2f855ad2e.zip
Fix for Bug #1085949 (Use ImageMagick fallback when importing bitmap resolution).
Fixed bugs: - https://launchpad.net/bugs/1085949 (bzr r12330)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/image-resolution.cpp33
-rw-r--r--src/extension/internal/image-resolution.h23
2 files changed, 45 insertions, 11 deletions
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index 51a3fe9c1..3c254a59c 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -21,6 +21,9 @@
#ifdef HAVE_JPEG
#define IR_TRY_JFIF 1
#endif
+#ifdef WITH_IMAGE_MAGICK
+#include <Magick++.h>
+#endif
namespace Inkscape {
namespace Extension {
@@ -39,6 +42,9 @@ ImageResolution::ImageResolution(char const *fn) {
if (!ok_) {
readexif(fn);
}
+ if (!ok_) {
+ readmagick(fn);
+ }
}
bool ImageResolution::ok() const {
@@ -328,6 +334,33 @@ void ImageResolution::readjfif(char const *) {
#endif
+#ifdef WITH_IMAGE_MAGICK
+void ImageResolution::readmagick(char const *fn) {
+ Magick::Image image;
+ try {
+ image.read(fn);
+ } catch (...) {}
+ Magick::Geometry geo = image.density();
+ std::string type = image.magick();
+
+ if (type == "PNG") { // PNG only supports pixelspercentimeter
+ x_ = (double)geo.width() * 2.54;
+ y_ = (double)geo.height() * 2.54;
+ } else {
+ x_ = (double)geo.width();
+ y_ = (double)geo.height();
+ }
+ ok_ = true;
+}
+
+#else
+
+// Dummy implementation
+void ImageResolution::readmagick(char const *) {
+}
+
+#endif /* WITH_IMAGE_MAGICK */
+
}
}
}
diff --git a/src/extension/internal/image-resolution.h b/src/extension/internal/image-resolution.h
index c42260f7d..6c4928a35 100644
--- a/src/extension/internal/image-resolution.h
+++ b/src/extension/internal/image-resolution.h
@@ -18,19 +18,20 @@ namespace Internal {
class ImageResolution {
public:
- ImageResolution(char const *fn);
- bool ok() const;
- double x() const;
- double y() const;
+ ImageResolution(char const *fn);
+ bool ok() const;
+ double x() const;
+ double y() const;
private:
- bool ok_;
- double x_;
- double y_;
+ bool ok_;
+ double x_;
+ double y_;
private:
- void readpng(char const *fn);
- void readexif(char const *fn);
- void readexiv(char const *fn);
- void readjfif(char const *fn);
+ void readpng(char const *fn);
+ void readexif(char const *fn);
+ void readexiv(char const *fn);
+ void readjfif(char const *fn);
+ void readmagick(char const *fn);
};
}