diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2013-05-12 12:49:26 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2013-05-12 12:49:26 +0000 |
| commit | 5a75b3f90a53941f04f32dc8f22c25f2f855ad2e (patch) | |
| tree | c032185f29cab12ac026ce7926c74315fb80519d /src/extension/internal/image-resolution.cpp | |
| parent | Fix for Bug #448872 (Changing the bounding box type in preferences does not u... (diff) | |
| download | inkscape-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/extension/internal/image-resolution.cpp')
| -rw-r--r-- | src/extension/internal/image-resolution.cpp | 33 |
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 */ + } } } |
