summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/pdftoppm.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc
index 1789aadf..97fdbea2 100644
--- a/utils/pdftoppm.cc
+++ b/utils/pdftoppm.cc
@@ -628,23 +628,34 @@ int main(int argc, char *argv[])
if (scaleDimensionBeforeRotation && needToRotate(doc->getPageRotate(pg)))
std::swap(pg_w, pg_h);
+ // Handle requests for specific image size
if (scaleTo != 0) {
resolution = (72.0 * scaleTo) / (pg_w > pg_h ? pg_w : pg_h);
x_resolution = y_resolution = resolution;
+ pg_w = pg_h = scaleTo;
} else {
if (x_scaleTo > 0) {
x_resolution = (72.0 * x_scaleTo) / pg_w;
+ pg_w = x_scaleTo;
if (y_scaleTo == -1)
y_resolution = x_resolution;
}
+
if (y_scaleTo > 0) {
y_resolution = (72.0 * y_scaleTo) / pg_h;
+ pg_h = y_scaleTo;
if (x_scaleTo == -1)
x_resolution = y_resolution;
}
+
+ // No specific image size requested---compute the size from the resolution
+ if (x_scaleTo <= 0) {
+ pg_w = pg_w * (x_resolution / 72.0);
+ }
+ if (y_scaleTo <= 0) {
+ pg_h = pg_h * (y_resolution / 72.0);
+ }
}
- pg_w = pg_w * (x_resolution / 72.0);
- pg_h = pg_h * (y_resolution / 72.0);
if (!scaleDimensionBeforeRotation && needToRotate(doc->getPageRotate(pg)))
std::swap(pg_w, pg_h);