From 83b3bef7bbf7ce54e08ca9dd649f5a4f4caa9dd1 Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Wed, 4 May 2016 01:11:00 -0500 Subject: [PATCH] pdftoppm: Calculate rotation before scaling Scaling (-scale-to-x and -scale-to-y) width and height get swapped if a page is rotated. Fix by moving scale calculation to after rotation calculation. bug #95268 --- utils/pdftoppm.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index 3574595..315c3e1 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -493,6 +493,11 @@ int main(int argc, char *argv[]) { pg_h = doc->getPageMediaHeight(pg); } + if ((doc->getPageRotate(pg) == 90) || (doc->getPageRotate(pg) == 270)) { + tmp = pg_w; + pg_w = pg_h; + pg_h = tmp; + } if (scaleTo != 0) { resolution = (72.0 * scaleTo) / (pg_w > pg_h ? pg_w : pg_h); x_resolution = y_resolution = resolution; @@ -510,11 +515,6 @@ int main(int argc, char *argv[]) { } pg_w = pg_w * (x_resolution / 72.0); pg_h = pg_h * (y_resolution / 72.0); - if ((doc->getPageRotate(pg) == 90) || (doc->getPageRotate(pg) == 270)) { - tmp = pg_w; - pg_w = pg_h; - pg_h = tmp; - } if (ppmRoot != NULL) { const char *ext = png ? "png" : (jpeg || jpegcmyk) ? "jpg" : tiff ? "tif" : mono ? "pbm" : gray ? "pgm" : "ppm"; if (singleFile) { -- 2.8.1