summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/image-resolution.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-07-14 21:09:41 +0000
committerMarkus Engel <markus.engel@tum.de>2013-07-14 21:09:41 +0000
commitd32efb61f1c2c18d1018e510bbe9bafc04a03905 (patch)
treeb447bf9856baf1cf485e38c4ce55edb27285129e /src/extension/internal/image-resolution.cpp
parentMerged from trunk (r12305) (diff)
parentMinor C++ish refactoring pass. (diff)
downloadinkscape-d32efb61f1c2c18d1018e510bbe9bafc04a03905.tar.gz
inkscape-d32efb61f1c2c18d1018e510bbe9bafc04a03905.zip
Merged from trunk (r12419).
(bzr r11608.1.107)
Diffstat (limited to 'src/extension/internal/image-resolution.cpp')
-rw-r--r--src/extension/internal/image-resolution.cpp33
1 files changed, 33 insertions, 0 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 */
+
}
}
}