summaryrefslogtreecommitdiffstats
path: root/src/extension/internal/image-resolution.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/extension/internal/image-resolution.cpp')
-rw-r--r--src/extension/internal/image-resolution.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index 3c254a59c..b38b0ddc7 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -11,16 +11,25 @@
# include <config.h>
#endif
+#include "util/units.h"
#include "image-resolution.h"
#define IR_TRY_PNG 1
+#include <png.h>
+
#ifdef HAVE_EXIF
-#define IR_TRY_EXIF 1
+#include <math.h>
+#include <libexif/exif-data.h>
#endif
+
#define IR_TRY_EXIV 0
+
#ifdef HAVE_JPEG
#define IR_TRY_JFIF 1
+#include <jpeglib.h>
+#include <setjmp.h>
#endif
+
#ifdef WITH_IMAGE_MAGICK
#include <Magick++.h>
#endif
@@ -62,8 +71,6 @@ double ImageResolution::y() const {
#if IR_TRY_PNG
-
-#include <png.h>
static bool haspngheader(FILE *fp) {
unsigned char header[8];
@@ -133,9 +140,6 @@ void ImageResolution::readpng(char const *) {
#if IR_TRY_EXIF
-#include <math.h>
-#include <libexif/exif-data.h>
-
static double exifDouble(ExifEntry *entry, ExifByteOrder byte_order) {
switch (entry->format) {
case EXIF_FORMAT_BYTE: {
@@ -264,9 +268,6 @@ void ImageResolution::readexiv(char const *) {
#if IR_TRY_JFIF
-#include <jpeglib.h>
-#include <setjmp.h>
-
static void irjfif_error_exit(j_common_ptr cinfo) {
longjmp(*(jmp_buf*)cinfo->client_data, 1);
}
@@ -341,15 +342,9 @@ void ImageResolution::readmagick(char const *fn) {
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();
- }
+
+ x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px");
+ y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px");
ok_ = true;
}