summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2012-03-01 21:43:32 +1030
committerAdrian Johnson <ajohnson@redneon.com>2012-03-01 21:43:32 +1030
commitfa82a7ce1372e5976ad95624115fcd7a4d9bd22c (patch)
treee0f41af9a8f6cc23038bdd0bc0b9b39812ae3048 /utils
parenta2b008223ad6887f00d76c535f2b0b0f13f52b76 (diff)
pdftocairo: allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved
Diffstat (limited to 'utils')
-rw-r--r--utils/pdftocairo.18
-rw-r--r--utils/pdftocairo.cc8
2 files changed, 12 insertions, 4 deletions
diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1
index 28e181f3..d02095ee 100644
--- a/utils/pdftocairo.1
+++ b/utils/pdftocairo.1
@@ -115,10 +115,14 @@ Specifies the Y resolution, in pixels per inch of image files (or rasterized reg
Scales each page to fit in scale-to*scale-to pixel box (PNG/JPEG only).
.TP
.BI \-scale-to-x " number"
-Scales each page horizontally to fit in scale-to-x pixels (PNG/JPEG only).
+Scales each page horizontally to fit in scale-to-x pixels. If
+scale-to-y is set to -1, the vertical size will determined by the
+aspect ratio of the page (PNG/JPEG only).
.TP
.BI \-scale-to-y " number"
-Scales each page vertically to fit in scale-to-y pixels (PNG/JPEG only).
+Scales each page vertically to fit in scale-to-y pixels. If scale-to-x
+is set to -1, the horizontal size will determined by the aspect ratio
+of the page (PNG/JPEG only).
.TP
.BI \-x " number"
Specifies the x-coordinate of the crop area top left corner in pixels (image output) or points (vector output)
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 0d920ac3..2eeb7511 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -952,11 +952,15 @@ int main(int argc, char *argv[]) {
resolution = (72.0 * scaleTo) / (pg_w > pg_h ? pg_w : pg_h);
x_resolution = y_resolution = resolution;
} else {
- if (x_scaleTo != 0) {
+ if (x_scaleTo > 0) {
x_resolution = (72.0 * x_scaleTo) / pg_w;
+ if (y_scaleTo == -1)
+ y_resolution = x_resolution;
}
- if (y_scaleTo != 0) {
+ if (y_scaleTo > 0) {
y_resolution = (72.0 * y_scaleTo) / pg_h;
+ if (x_scaleTo == -1)
+ x_resolution = y_resolution;
}
}
if ((doc->getPageRotate(pg) == 90) || (doc->getPageRotate(pg) == 270)) {