From 2a46d10f80dff9e4d50167a40abcecfa83c405ca Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sat, 25 Feb 2012 20:02:22 +1030 Subject: [PATCH 1/2] pdftoppm: allow one of -scale-to-[xy] = -1 to mean the aspect ratio is to be preserved bug 43393 --- utils/pdftoppm.1 | 8 ++++++-- utils/pdftoppm.cc | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1 index 5fc81dc..17a3282 100644 --- a/utils/pdftoppm.1 +++ b/utils/pdftoppm.1 @@ -51,10 +51,14 @@ Specifies the Y resolution, in DPI. The default is 150 DPI. Scales each page to fit in scale-to*scale-to pixel box. .TP .BI \-scale-to-x " number" -Scales each page horizontally to fit in scale-to-x pixels. +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. .TP .BI \-scale-to-y " number" -Scales each page vertically to fit in scale-to-y pixels. +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. .TP .BI \-x " number" Specifies the x-coordinate of the crop area top left corner diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index 222c89b..5ceb0a0 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -389,11 +389,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; } } pg_w = pg_w * (x_resolution / 72.0); -- 1.7.5.4